diff options
author | Jhon Honce <jhonce@redhat.com> | 2021-03-18 12:17:11 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2021-03-19 09:25:12 -0700 |
commit | 417f36281129434cfa57fcaffb7f10b28b36e2e6 (patch) | |
tree | 90be7fc3ea5a614dcc889ade4477ec6483b91a89 /libpod | |
parent | 5325957d536be3515fb7a782e4755afca38fca4c (diff) | |
download | podman-417f36281129434cfa57fcaffb7f10b28b36e2e6.tar.gz podman-417f36281129434cfa57fcaffb7f10b28b36e2e6.tar.bz2 podman-417f36281129434cfa57fcaffb7f10b28b36e2e6.zip |
Cleanup /libpod/images/load handler
* Remove orphaned code
* Add meaningful error from LoadImageFromSingleImageArchive() when
heuristic fails to determine payload format
* Correct swagger to output correct types and headers
Signed-off-by: Jhon Honce <jhonce@redhat.com>
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") } |