diff options
author | Kunal Kushwaha <kunal.kushwaha@gmail.com> | 2020-03-19 11:39:39 +0900 |
---|---|---|
committer | Kunal Kushwaha <kunal.kushwaha@gmail.com> | 2020-04-15 02:49:47 +0000 |
commit | 9dc9f5cf4cc5d0c688263d5532ece0d3079c6d4a (patch) | |
tree | 134ea614a6475d3dadbda2c019a168925a1b7427 /libpod/image/image.go | |
parent | c0e29b4a31e330927b7a980209b2aae192f9bafe (diff) | |
download | podman-9dc9f5cf4cc5d0c688263d5532ece0d3079c6d4a.tar.gz podman-9dc9f5cf4cc5d0c688263d5532ece0d3079c6d4a.tar.bz2 podman-9dc9f5cf4cc5d0c688263d5532ece0d3079c6d4a.zip |
image prune skips images with child images.
While image build process, intermediate images are created.
These images are also used as cache images, used in rebuilding
same images. This fix the deletion of cache images.
Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r-- | libpod/image/image.go | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 80cc6f15a..7198a42a3 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -32,10 +32,10 @@ import ( "github.com/containers/libpod/pkg/registries" "github.com/containers/libpod/pkg/util" "github.com/containers/storage" - "github.com/opencontainers/go-digest" + digest "github.com/opencontainers/go-digest" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" ociv1 "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/opentracing/opentracing-go" + opentracing "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -847,6 +847,26 @@ func (i *Image) Dangling() bool { return len(i.Names()) == 0 } +// Intermediate returns true if the image is cache or intermediate image. +// Cache image has parent and child. +func (i *Image) Intermediate(ctx context.Context) (bool, error) { + parent, err := i.IsParent(ctx) + if err != nil { + return false, err + } + if !parent { + return false, nil + } + img, err := i.GetParent(ctx) + if err != nil { + return false, err + } + if img != nil { + return true, nil + } + return false, nil +} + // Labels returns the image's labels func (i *Image) Labels(ctx context.Context) (map[string]string, error) { imgInspect, err := i.imageInspectInfo(ctx) |