mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Merge pull request #10230 from matejvasek/fix-compat-img-get
fix: docker APIv2 `images/get`
This commit is contained in:
@ -443,7 +443,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
|
|
||||||
query := struct {
|
query := struct {
|
||||||
Names string `schema:"names"`
|
Names []string `schema:"names"`
|
||||||
}{
|
}{
|
||||||
// This is where you can override the golang default value for one of fields
|
// This is where you can override the golang default value for one of fields
|
||||||
}
|
}
|
||||||
@ -451,8 +451,16 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
|
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
images := make([]string, 0)
|
if len(query.Names) <= 0 {
|
||||||
images = append(images, strings.Split(query.Names, ",")...)
|
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")
|
tmpfile, err := ioutil.TempFile("", "api.tar")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
|
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to create tempfile"))
|
||||||
@ -466,7 +474,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
imageEngine := abi.ImageEngine{Libpod: runtime}
|
imageEngine := abi.ImageEngine{Libpod: runtime}
|
||||||
|
|
||||||
saveOptions := entities.ImageSaveOptions{Output: tmpfile.Name()}
|
saveOptions := entities.ImageSaveOptions{Format: "docker-archive", Output: tmpfile.Name()}
|
||||||
if err := imageEngine.Save(r.Context(), images[0], images[1:], saveOptions); err != nil {
|
if err := imageEngine.Save(r.Context(), images[0], images[1:], saveOptions); err != nil {
|
||||||
utils.InternalServerError(w, err)
|
utils.InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
|
@ -140,16 +140,15 @@ t GET images/json?filters='{"reference":["test1"]}' 200 length=1
|
|||||||
|
|
||||||
t DELETE libpod/images/test1:latest 200
|
t DELETE libpod/images/test1:latest 200
|
||||||
|
|
||||||
# Export more than one image
|
t GET "images/get?names=alpine" 200 '[POSIX tar archive]'
|
||||||
# FIXME FIXME FIXME, this doesn't work:
|
|
||||||
# not ok 64 [10-images] GET images/get?names=alpine,busybox : status
|
podman pull busybox
|
||||||
# expected: 200
|
#t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]'
|
||||||
# actual: 500
|
#img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length")
|
||||||
# expected: 200
|
#is "$img_cnt" 2 "number of images in tar archive"
|
||||||
# not ok 65 [10-images] GET images/get?names=alpine,busybox : output
|
# TODO getting multiple images is not supported yet
|
||||||
# expected: [POSIX tar archive]
|
# once it is supported replace the test below by the tests above
|
||||||
# actual: {"cause":"no such image","message":"unable to find a name and tag match for busybox in repotags: no such image","response":500}
|
t GET "images/get?names=alpine&names=busybox" 501 \
|
||||||
#
|
.cause="getting multiple image is not supported yet"
|
||||||
#t GET images/get?names=alpine,busybox 200 '[POSIX tar archive]'
|
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
Reference in New Issue
Block a user