From 88deb3934f59e452a5385c2cc5c58dda8b9bd1b6 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Tue, 24 Oct 2017 10:41:32 -0400 Subject: [PATCH] Update PushImage() for newer containers/image The updated containers/image and containers/storage don't require as many workarounds to be able to push images. Signed-off-by: Nalin Dahyabhai --- libpod/runtime_img.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index feb0ef3f..9e7ad310 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -13,7 +13,6 @@ import ( dockerarchive "github.com/containers/image/docker/archive" "github.com/containers/image/docker/reference" "github.com/containers/image/docker/tarfile" - "github.com/containers/image/manifest" ociarchive "github.com/containers/image/oci/archive" "github.com/containers/image/pkg/sysregistries" "github.com/containers/image/signature" @@ -377,24 +376,11 @@ func (r *Runtime) PushImage(source string, destination string, options CopyOptio return err } defer policyContext.Destroy() - // Look up the image name and its layer, then build the imagePushData from - // the image - img, err := r.getImage(source) - if err != nil { - return errors.Wrapf(err, "error locating image %q for importing settings", source) - } - cd, err := r.ImportCopyDataFromImage(r.imageContext, img.ID, "", "") - if err != nil { - return err - } - // Give the image we're producing the same ancestors as its source image - cd.FromImage = cd.Docker.ContainerConfig.Image - cd.FromImageID = string(cd.Docker.Parent) - // Prep the layers and manifest for export - src, err := cd.MakeImageRef(manifest.GuessMIMEType(cd.Manifest), options.Compression, img.Names, img.TopLayer, nil) + // Look up the source image, expecting it to be in local storage + src, err := is.Transport.ParseStoreReference(r.store, source) if err != nil { - return errors.Wrapf(err, "error copying layers and metadata") + return errors.Wrapf(err, "error getting source imageReference for %q", source) } copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, nil, &options.DockerRegistryOptions, options.SigningOptions, options.AuthFile)