aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-02 01:22:44 +0200
committerGitHub <noreply@github.com>2019-08-02 01:22:44 +0200
commite48dc506d18335b36d1ffbbc8df1890ee3b99e2c (patch)
tree9bfeffca310068bc8ed23024756dcd6540239ea6
parent1bbcb2fc56c1655269930c83628ef5f5802f1887 (diff)
parent619a39f7bb2275a086651fcf31619959f6d15c6b (diff)
downloadpodman-e48dc506d18335b36d1ffbbc8df1890ee3b99e2c.tar.gz
podman-e48dc506d18335b36d1ffbbc8df1890ee3b99e2c.tar.bz2
podman-e48dc506d18335b36d1ffbbc8df1890ee3b99e2c.zip
Merge pull request #3693 from QiWang19/search
fix search output limit
-rw-r--r--docs/podman-search.1.md4
-rw-r--r--libpod/image/search.go7
-rw-r--r--test/e2e/search_test.go12
3 files changed, 18 insertions, 5 deletions
diff --git a/docs/podman-search.1.md b/docs/podman-search.1.md
index f0a696494..c68f94347 100644
--- a/docs/podman-search.1.md
+++ b/docs/podman-search.1.md
@@ -11,8 +11,8 @@ podman\-search - Search a registry for an image
The user can specify which registry to search by prefixing the registry in the search term
(example **registry.fedoraproject.org/fedora**), default is the registries in the
**registries.search** table in the config file - **/etc/containers/registries.conf**.
-The number of results can be limited using the **--limit** flag. If more than one registry
-is being searched, the limit will be applied to each registry. The output can be filtered
+The default number of results is 25. The number of results can be limited using the **--limit** flag.
+If more than one registry is being searched, the limit will be applied to each registry. The output can be filtered
using the **--filter** flag. To get all available images in a registry without a specific
search term, the user can just enter the registry name with a trailing "/" (example **registry.fedoraproject.org/**).
Note, searching without a search term will only work for registries that implement the v2 API.
diff --git a/libpod/image/search.go b/libpod/image/search.go
index e557431c6..82ef4f75a 100644
--- a/libpod/image/search.go
+++ b/libpod/image/search.go
@@ -162,8 +162,11 @@ func searchImageInRegistry(term string, registry string, options SearchOptions)
if len(results) < limit {
limit = len(results)
}
- if options.Limit != 0 && options.Limit < len(results) {
- limit = options.Limit
+ if options.Limit != 0 {
+ limit = len(results)
+ if options.Limit < len(results) {
+ limit = options.Limit
+ }
}
paramsArr := []SearchResult{}
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go
index 3b1da859c..9c28849f0 100644
--- a/test/e2e/search_test.go
+++ b/test/e2e/search_test.go
@@ -118,10 +118,20 @@ registries = ['{{.Host}}:{{.Port}}']`
})
It("podman search limit flag", func() {
- search := podmanTest.Podman([]string{"search", "--limit", "3", "docker.io/alpine"})
+ search := podmanTest.Podman([]string{"search", "docker.io/alpine"})
+ search.WaitWithDefaultTimeout()
+ Expect(search.ExitCode()).To(Equal(0))
+ Expect(len(search.OutputToStringArray())).To(Equal(26))
+
+ search = podmanTest.Podman([]string{"search", "--limit", "3", "docker.io/alpine"})
search.WaitWithDefaultTimeout()
Expect(search.ExitCode()).To(Equal(0))
Expect(len(search.OutputToStringArray())).To(Equal(4))
+
+ search = podmanTest.Podman([]string{"search", "--limit", "30", "docker.io/alpine"})
+ search.WaitWithDefaultTimeout()
+ Expect(search.ExitCode()).To(Equal(0))
+ Expect(len(search.OutputToStringArray())).To(Equal(31))
})
It("podman search with filter stars", func() {