summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-12-02 13:25:54 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-12-02 14:29:17 +0100
commit2683ecbbcda750b9339713ced9b974b9dd61b9aa (patch)
tree688253d18590ae0fdf4fa110207e2bfc18d4e0b7
parenteeb71490e57047202410821fe98fa4332371cb03 (diff)
downloadpodman-2683ecbbcda750b9339713ced9b974b9dd61b9aa.tar.gz
podman-2683ecbbcda750b9339713ced9b974b9dd61b9aa.tar.bz2
podman-2683ecbbcda750b9339713ced9b974b9dd61b9aa.zip
compat: images/json
Do not list manifest lists. Docker doesn't either. Fixes: #12453 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
-rw-r--r--pkg/api/handlers/compat/images.go12
-rw-r--r--test/apiv2/10-images.at7
2 files changed, 16 insertions, 3 deletions
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index af8b6b63d..4533fddeb 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -409,14 +409,20 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Failed get images"))
return
}
- var summaries = make([]*entities.ImageSummary, len(images))
- for j, img := range images {
+
+ summaries := make([]*entities.ImageSummary, 0, len(images))
+ for _, img := range images {
+ // If the image is a manifest list, extract as much as we can.
+ if isML, _ := img.IsManifestList(r.Context()); isML {
+ continue
+ }
+
is, err := handlers.ImageToImageSummary(img)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "Failed transform image summaries"))
return
}
- summaries[j] = is
+ summaries = append(summaries, is)
}
utils.WriteResponse(w, http.StatusOK, summaries)
}
diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at
index b7bcaf81d..e67f559f3 100644
--- a/test/apiv2/10-images.at
+++ b/test/apiv2/10-images.at
@@ -10,6 +10,13 @@ t GET libpod/images/json 200 \
.[0].Id~[0-9a-f]\\{64\\}
iid=$(jq -r '.[0].Id' <<<"$output")
+# Create an empty manifest and make sure it is not listed
+# in the compat endpoint.
+t GET images/json 200 length=1
+podman manifest create foo
+t GET images/json 200 length=1
+t GET libpod/images/json 200 length=2
+
t GET libpod/images/$iid/exists 204
t GET libpod/images/$PODMAN_TEST_IMAGE_NAME/exists 204
t GET libpod/images/${iid}abcdef/exists 404 \