From 5507f15ba58a271c018a5446ef091ee477b18b1d Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Sat, 28 Jul 2018 08:06:08 +0200 Subject: Replace Runtime.LoadFromArchive with Runtime.LoadFromArchiveReference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All callers of LoadFromArchive expect the input to be in the transport:name format, or create it that way. So, pass a types.ImageReference instead of a string. That requires us to add an explicit parse step in (podman pull); in (podman load) we can, instead of pasting strings, create native objects directly. Changes the error behavior of (podman pull), we no longer try heuristically parsing docker-archive:... inputs as Docker references. Also changes the string reported by (podman load) if all parsing attempts fail, to be only the path instead of dir:path. The error message itself is likely to be the same (from directory.Transport). (While at it, update a mismatched comment.) Signed-off-by: Miloslav Trmač Closes: #1176 Approved by: rhatdan --- libpod/image/image.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libpod') diff --git a/libpod/image/image.go b/libpod/image/image.go index c8918f11e..964a13585 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -159,17 +159,17 @@ func (ir *Runtime) New(ctx context.Context, name, signaturePolicyPath, authfile return &newImage, nil } -// LoadFromArchive creates a new image object for images pulled from a tar archive (podman load) +// LoadFromArchiveReference creates a new image object for images pulled from a tar archive and the like (podman load) // This function is needed because it is possible for a tar archive to have multiple tags for one image -func (ir *Runtime) LoadFromArchive(ctx context.Context, name, signaturePolicyPath string, writer io.Writer) ([]*Image, error) { +func (ir *Runtime) LoadFromArchiveReference(ctx context.Context, srcRef types.ImageReference, signaturePolicyPath string, writer io.Writer) ([]*Image, error) { var newImages []*Image if signaturePolicyPath == "" { signaturePolicyPath = ir.SignaturePolicyPath } - imageNames, err := ir.pullImage(ctx, name, writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false) + imageNames, err := ir.pullImage(ctx, transports.ImageName(srcRef), writer, "", signaturePolicyPath, SigningOptions{}, &DockerRegistryOptions{}, false) if err != nil { - return nil, errors.Wrapf(err, "unable to pull %s", name) + return nil, errors.Wrapf(err, "unable to pull %s", transports.ImageName(srcRef)) } for _, name := range imageNames { -- cgit v1.2.3-54-g00ecf