From ad2efbe9e1e2873e7c7f93804a9303bd2158857a Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 29 Jul 2020 18:41:42 +0200 Subject: [PATCH 1/3] Add test case for description being present in search result Test for a specific static image and match the description to avoid regression like https://github.com/containers/podman/pull/7131 Signed-off-by: Ralf Haferkamp --- test/e2e/search_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 1e7dff697f..104bb4ec87 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "regexp" "strconv" "text/template" @@ -98,6 +99,15 @@ registries = ['{{.Host}}:{{.Port}}']` Expect(search.LineInOutputContains("quay.io/libpod/gate")).To(BeTrue()) }) + It("podman search image with description", func() { + search := podmanTest.Podman([]string{"search", "quay.io/libpod/whalesay"}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Equal(0)) + output := fmt.Sprintf("%s", search.Out.Contents()) + match, _ := regexp.MatchString(`(?m)^quay.io\s+quay.io/libpod/whalesay\s+Static image used for automated testing.+$`, output) + Expect(match).To(BeTrue()) + }) + It("podman search format flag", func() { search := podmanTest.Podman([]string{"search", "--format", "table {{.Index}} {{.Name}}", "alpine"}) search.WaitWithDefaultTimeout() From bcbb5f9963e9b08ddaeb895d074e98f176a39bc0 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 30 Jul 2020 14:22:05 +0200 Subject: [PATCH 2/3] API: Fix 'podman image search` missing description `podman image search` returned wrong results for the image "Description" as it was mapped to the wrong field ("ID") in the search results. Basically cherry-picked into the api from commit cf5c63b5c492e41d72b6e3b6d75b5f39b0a957fd. Signed-off-by: Ralf Haferkamp --- pkg/api/handlers/libpod/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index 3421f0836f..aaa2c4330a 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -677,7 +677,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { for i := range searchResults { reports[i].Index = searchResults[i].Index reports[i].Name = searchResults[i].Name - reports[i].Description = searchResults[i].Index + reports[i].Description = searchResults[i].Description reports[i].Stars = searchResults[i].Stars reports[i].Official = searchResults[i].Official reports[i].Automated = searchResults[i].Automated From 54256fbe7881894063f27e19e7dc63cb7c358e0c Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Fri, 31 Jul 2020 13:16:20 +0200 Subject: [PATCH 3/3] Make `search --no-trunc` work for podman remote The HTTP API for image search was still lacking support of the NoTrunc parameter. Signed-off-by: Ralf Haferkamp --- pkg/api/handlers/libpod/images.go | 4 +++- pkg/api/server/register_images.go | 4 ++++ pkg/bindings/images/images.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index aaa2c4330a..e0da990c33 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -638,6 +638,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { query := struct { Term string `json:"term"` Limit int `json:"limit"` + NoTrunc bool `json:"noTrunc"` Filters []string `json:"filters"` TLSVerify bool `json:"tlsVerify"` }{ @@ -650,7 +651,8 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { } options := image.SearchOptions{ - Limit: query.Limit, + Limit: query.Limit, + NoTrunc: query.NoTrunc, } if _, found := r.URL.Query()["tlsVerify"]; found { options.InsecureSkipTLSVerify = types.NewOptionalBool(!query.TLSVerify) diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 7f060d0980..cb4ce4fe7c 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -972,6 +972,10 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // type: integer // description: maximum number of results // - in: query + // name: noTrunc + // type: boolean + // description: do not truncate any of the result strings + // - in: query // name: filters // type: string // description: | diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index fc8c9996e9..12d1a9ce9d 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -439,6 +439,7 @@ func Search(ctx context.Context, term string, opts entities.ImageSearchOptions) params := url.Values{} params.Set("term", term) params.Set("limit", strconv.Itoa(opts.Limit)) + params.Set("noTrunc", strconv.FormatBool(opts.NoTrunc)) for _, f := range opts.Filters { params.Set("filters", f) }