mirror of
https://github.com/containers/podman.git
synced 2025-12-04 20:28:40 +08:00
vendor: update c/{common,storage}
Closes: https://github.com/containers/podman/issues/25572 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
31
vendor/github.com/containers/common/libimage/layer_tree.go
generated
vendored
31
vendor/github.com/containers/common/libimage/layer_tree.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/containers/storage"
|
||||
storageTypes "github.com/containers/storage/types"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -22,6 +23,10 @@ type layerTree struct {
|
||||
// emptyImages do not have any top-layer so we cannot create a
|
||||
// *layerNode for them.
|
||||
emptyImages []*Image
|
||||
// manifestList keep track of images based on their digest.
|
||||
// Library will use this map when checking if a image is dangling.
|
||||
// If an image is used in a manifestList it is NOT dangling
|
||||
manifestListDigests map[digest.Digest]struct{}
|
||||
}
|
||||
|
||||
// node returns a layerNode for the specified layerID.
|
||||
@@ -90,20 +95,21 @@ func (l *layerNode) repoTags() ([]string, error) {
|
||||
}
|
||||
|
||||
// newFreshLayerTree extracts a layerTree from consistent layers and images in the local storage.
|
||||
func (r *Runtime) newFreshLayerTree() (*layerTree, error) {
|
||||
func (r *Runtime) newFreshLayerTree(ctx context.Context) (*layerTree, error) {
|
||||
images, layers, err := r.getImagesAndLayers()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.newLayerTreeFromData(images, layers)
|
||||
return r.newLayerTreeFromData(ctx, images, layers, false)
|
||||
}
|
||||
|
||||
// newLayerTreeFromData extracts a layerTree from the given the layers and images.
|
||||
// The caller is responsible for (layers, images) being consistent.
|
||||
func (r *Runtime) newLayerTreeFromData(images []*Image, layers []storage.Layer) (*layerTree, error) {
|
||||
func (r *Runtime) newLayerTreeFromData(ctx context.Context, images []*Image, layers []storage.Layer, generateManifestDigestList bool) (*layerTree, error) {
|
||||
tree := layerTree{
|
||||
nodes: make(map[string]*layerNode),
|
||||
ociCache: make(map[string]*ociv1.Image),
|
||||
nodes: make(map[string]*layerNode),
|
||||
ociCache: make(map[string]*ociv1.Image),
|
||||
manifestListDigests: make(map[digest.Digest]struct{}),
|
||||
}
|
||||
|
||||
// First build a tree purely based on layer information.
|
||||
@@ -124,6 +130,21 @@ func (r *Runtime) newLayerTreeFromData(images []*Image, layers []storage.Layer)
|
||||
topLayer := img.TopLayer()
|
||||
if topLayer == "" {
|
||||
tree.emptyImages = append(tree.emptyImages, img)
|
||||
// When img is a manifest list, cache the lists of
|
||||
// digests refereenced in manifest list. Digests can
|
||||
// be used to check for dangling images.
|
||||
if !generateManifestDigestList {
|
||||
continue
|
||||
}
|
||||
if manifestList, _ := img.IsManifestList(ctx); manifestList {
|
||||
mlist, err := img.ToManifestList()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, digest := range mlist.list.Instances() {
|
||||
tree.manifestListDigests[digest] = struct{}{}
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
node, exists := tree.nodes[topLayer]
|
||||
|
||||
Reference in New Issue
Block a user