summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-05-07 12:28:26 -0400
committerGitHub <noreply@github.com>2021-05-07 12:28:26 -0400
commit0ce6a65b3961465593470c3457d75b0a846c8d98 (patch)
tree4564ec30273c56cdd0607ca70635f2a627f0ff51 /pkg
parent5616887f62b4bed1031cdade8bd602bc2cb9d8f4 (diff)
parent766659917f9b0b47c722d0c08707841bd1c649ae (diff)
downloadpodman-0ce6a65b3961465593470c3457d75b0a846c8d98.tar.gz
podman-0ce6a65b3961465593470c3457d75b0a846c8d98.tar.bz2
podman-0ce6a65b3961465593470c3457d75b0a846c8d98.zip
Merge pull request #10230 from matejvasek/fix-compat-img-get
fix: docker APIv2 `images/get`
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/images.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index 0b9367a17..4b7a2a71c 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -443,7 +443,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
query := struct {
- Names string `schema:"names"`
+ Names []string `schema:"names"`
}{
// 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()))
return
}
- images := make([]string, 0)
- images = append(images, strings.Split(query.Names, ",")...)
+ if len(query.Names) <= 0 {
+ 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")
if err != nil {
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}
- 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 {
utils.InternalServerError(w, err)
return