Skip to content

Commit

Permalink
Merge pull request #10265 from matejvasek/fix-get-multiple-imgs-compat
Browse files Browse the repository at this point in the history
fix: compat API "images/get" for multiple images
  • Loading branch information
openshift-merge-robot authored May 8, 2021
2 parents 141d3f1 + c8deab8 commit 54bed10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 1 addition & 5 deletions pkg/api/handlers/compat/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,6 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, fmt.Errorf("no images to download"))
return
}
if len(query.Names) > 1 {
utils.Error(w, "Something went wrong.", http.StatusNotImplemented, fmt.Errorf("getting multiple image is not supported yet"))
return
}

images := query.Names
tmpfile, err := ioutil.TempFile("", "api.tar")
Expand All @@ -478,7 +474,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {

imageEngine := abi.ImageEngine{Libpod: runtime}

saveOptions := entities.ImageSaveOptions{Format: "docker-archive", Output: tmpfile.Name()}
saveOptions := entities.ImageSaveOptions{Format: "docker-archive", Output: tmpfile.Name(), MultiImageArchive: true}
if err := imageEngine.Save(r.Context(), images[0], images[1:], saveOptions); err != nil {
utils.InternalServerError(w, err)
return
Expand Down
10 changes: 3 additions & 7 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,8 @@ t DELETE libpod/images/test1:latest 200
t GET "images/get?names=alpine" 200 '[POSIX tar archive]'

podman pull busybox
#t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]'
#img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length")
#is "$img_cnt" 2 "number of images in tar archive"
# TODO getting multiple images is not supported yet
# once it is supported replace the test below by the tests above
t GET "images/get?names=alpine&names=busybox" 501 \
.cause="getting multiple image is not supported yet"
t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]'
img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length")
is "$img_cnt" 2 "number of images in tar archive"

# vim: filetype=sh

0 comments on commit 54bed10

Please sign in to comment.