From 9df31cfb7784b158308abc5eabb7ff5176011518 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Thu, 20 Jan 2022 17:40:27 +0530 Subject: 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 --- pkg/api/handlers/compat/images.go | 4 ++-- test/apiv2/10-images.at | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 23a9b12a3..4abd510bf 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -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 } diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index 36c2fc6aa..673858a3c 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -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 -- cgit v1.2.3-54-g00ecf From 1c0fdba4f2cfbabadcbd16933882dbb2fb2e77f8 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Fri, 21 Jan 2022 00:42:22 +0530 Subject: compat: remove hardcoded index from load images output report Signed-off-by: Aditya R --- pkg/api/handlers/compat/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 4abd510bf..401a7ec1b 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -511,7 +511,7 @@ func LoadImages(w http.ResponseWriter, r *http.Request) { utils.WriteResponse(w, http.StatusOK, struct { Stream string `json:"stream"` }{ - Stream: fmt.Sprintf("Loaded image: %s\n", loadReport.Names[0]), + Stream: fmt.Sprintf("Loaded image: %s", strings.Join(loadReport.Names, ",")), }) } -- cgit v1.2.3-54-g00ecf