diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-22 08:18:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 08:18:56 -0700 |
commit | 9ec936a856a90eeb6a6300cc8bbdc7e7fbdcb9f4 (patch) | |
tree | 6100fcd3fe6d486b98b94c8c13e2f22a98014043 /libpod | |
parent | c1f2f75f03853a7cd04dd5e5495700e5fdffcafd (diff) | |
parent | 417f36281129434cfa57fcaffb7f10b28b36e2e6 (diff) | |
download | podman-9ec936a856a90eeb6a6300cc8bbdc7e7fbdcb9f4.tar.gz podman-9ec936a856a90eeb6a6300cc8bbdc7e7fbdcb9f4.tar.bz2 podman-9ec936a856a90eeb6a6300cc8bbdc7e7fbdcb9f4.zip |
Merge pull request #9757 from jwhonce/wip/load
Cleanup /libpod/images/load handler
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/runtime_img.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 90b11f8ca..13ac42e7d 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -313,15 +313,23 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io func() (types.ImageReference, error) { return layout.NewReference(inputFile, "") }, + func() (types.ImageReference, error) { + // This item needs to be last to break out of loop and report meaningful error message + return nil, + errors.New("payload does not match any of the supported image formats (oci-archive, oci-dir, docker-archive, docker-dir)") + }, } { src, err := referenceFn() - if err == nil && src != nil { - newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer) - if err == nil { - return getImageNames(newImages), nil - } + if err != nil { saveErr = err + continue + } + + newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer) + if err == nil { + return getImageNames(newImages), nil } + saveErr = err } return "", errors.Wrapf(saveErr, "error pulling image") } |