diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-12 10:20:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-12 10:20:02 -0400 |
commit | 235f367861be6b7f9ca3b4a62c240a03728a7a21 (patch) | |
tree | 7e5a6f78fa65090d925e533dbf768b3ff83dd577 /libpod/image | |
parent | 19f5d557bc5d9c538d7a3992abeaa9f7fbb44166 (diff) | |
parent | 8741eb8a9201b930abb463c1128a48bdbcec70a0 (diff) | |
download | podman-235f367861be6b7f9ca3b4a62c240a03728a7a21.tar.gz podman-235f367861be6b7f9ca3b4a62c240a03728a7a21.tar.bz2 podman-235f367861be6b7f9ca3b4a62c240a03728a7a21.zip |
Merge pull request #5469 from giuseppe/no-size-create-container
create: do not calculate image size
Diffstat (limited to 'libpod/image')
-rw-r--r-- | libpod/image/image.go | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 43fd52a1a..5f914ed79 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -916,12 +916,7 @@ func (i *Image) imageInspectInfo(ctx context.Context) (*types.ImageInspectInfo, return i.inspectInfo, nil } -// Inspect returns an image's inspect data -func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) { - span, _ := opentracing.StartSpanFromContext(ctx, "imageInspect") - span.SetTag("type", "image") - defer span.Finish() - +func (i *Image) inspect(ctx context.Context, calculateSize bool) (*inspect.ImageData, error) { ociv1Img, err := i.ociv1Image(ctx) if err != nil { ociv1Img = &ociv1.Image{} @@ -936,8 +931,10 @@ func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) { } size := int64(-1) - if usize, err := i.Size(ctx); err == nil { - size = int64(*usize) + if calculateSize { + if usize, err := i.Size(ctx); err == nil { + size = int64(*usize) + } } repoTags, err := i.RepoTags() @@ -1002,6 +999,26 @@ func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) { return data, nil } +// Inspect returns an image's inspect data +func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) { + span, _ := opentracing.StartSpanFromContext(ctx, "imageInspect") + + span.SetTag("type", "image") + defer span.Finish() + + return i.inspect(ctx, true) +} + +// InspectNoSize returns an image's inspect data without calculating the size for the image +func (i *Image) InspectNoSize(ctx context.Context) (*inspect.ImageData, error) { + span, _ := opentracing.StartSpanFromContext(ctx, "imageInspectNoSize") + + span.SetTag("type", "image") + defer span.Finish() + + return i.inspect(ctx, false) +} + // Import imports and image into the store and returns an image func (ir *Runtime) Import(ctx context.Context, path, reference string, writer io.Writer, signingOptions SigningOptions, imageConfig ociv1.Image) (*Image, error) { src, err := tarball.Transport.ParseReference(path) |