From 2683ecbbcda750b9339713ced9b974b9dd61b9aa Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <rothberg@redhat.com>
Date: Thu, 2 Dec 2021 13:25:54 +0100
Subject: compat: images/json

Do not list manifest lists.  Docker doesn't either.

Fixes: #12453
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
---
 pkg/api/handlers/compat/images.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

(limited to 'pkg/api')

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)
 }
-- 
cgit v1.2.3-54-g00ecf