From 29358e3e0968c2b72712d11e0a412ebf5ea78417 Mon Sep 17 00:00:00 2001 From: Milivoje Legenovic Date: Thu, 17 Dec 2020 00:51:49 +0100 Subject: [PATCH] Docker compat API - /images/search returns wrong structure (#7857) Signed-off-by: Milivoje Legenovic --- pkg/api/handlers/compat/images_search.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/api/handlers/compat/images_search.go b/pkg/api/handlers/compat/images_search.go index b3ceae3ee9..6808cdad57 100644 --- a/pkg/api/handlers/compat/images_search.go +++ b/pkg/api/handlers/compat/images_search.go @@ -8,6 +8,7 @@ import ( "github.com/containers/podman/v2/libpod/image" "github.com/containers/podman/v2/pkg/api/handlers/utils" "github.com/containers/podman/v2/pkg/auth" + "github.com/docker/docker/api/types/registry" "github.com/gorilla/schema" "github.com/pkg/errors" ) @@ -77,5 +78,18 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { utils.BadRequest(w, "term", query.Term, err) return } - utils.WriteResponse(w, http.StatusOK, results) + + compatResults := make([]registry.SearchResult, 0, len(results)) + for _, result := range results { + compatResult := registry.SearchResult{ + Name: result.Name, + Description: result.Description, + StarCount: result.Stars, + IsAutomated: result.Automated == "[OK]", + IsOfficial: result.Official == "[OK]", + } + compatResults = append(compatResults, compatResult) + } + + utils.WriteResponse(w, http.StatusOK, compatResults) }