compat: images/load must be able to load tar with multiple images

`http:/host:port/images/load` fails to accept tar with more than one
images however manual load works as expected. Remove explicit check for
`1` image and only fail if result set has value less than `1`.

Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
Aditya R 2022-01-20 17:40:27 +05:30
parent 1d6e154a73
commit 9df31cfb77
No known key found for this signature in database
GPG Key ID: 8E5A8A19DF7C8673
2 changed files with 10 additions and 2 deletions

View File

@ -503,8 +503,8 @@ func LoadImages(w http.ResponseWriter, r *http.Request) {
return
}
if len(loadReport.Names) != 1 {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Errorf("%d instead of 1 were loaded", len(loadReport.Names)))
if len(loadReport.Names) < 1 {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Errorf("one or more images are required"))
return
}

View File

@ -197,6 +197,14 @@ t POST "build?dockerfile=containerfile" $CONTAINERFILE_TAR 200 \
t POST libpod/images/prune 200
t POST libpod/images/prune 200 length=0 []
# compat api must allow loading tar which contain multiple images
podman pull quay.io/libpod/alpine:latest quay.io/libpod/busybox:latest
podman save -o ${TMPD}/test.tar quay.io/libpod/alpine:latest quay.io/libpod/busybox:latest
t POST "images/load" ${TMPD}/test.tar 200 \
.stream="Loaded image: quay.io/libpod/busybox:latest,quay.io/libpod/alpine:latest"
t GET libpod/images/quay.io/libpod/alpine:latest/exists 204
t GET libpod/images/quay.io/libpod/busybox:latest/exists 204
cleanBuildTest
# vim: filetype=sh