mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
@ -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
|
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
|
(example **registry.fedoraproject.org/fedora**), default is the registries in the
|
||||||
**registries.search** table in the config file - **/etc/containers/registries.conf**.
|
**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
|
The default number of results is 25. The number of results can be limited using the **--limit** flag.
|
||||||
is being searched, the limit will be applied to each registry. The output can be filtered
|
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
|
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/**).
|
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.
|
Note, searching without a search term will only work for registries that implement the v2 API.
|
||||||
|
@ -162,9 +162,12 @@ func searchImageInRegistry(term string, registry string, options SearchOptions)
|
|||||||
if len(results) < limit {
|
if len(results) < limit {
|
||||||
limit = len(results)
|
limit = len(results)
|
||||||
}
|
}
|
||||||
if options.Limit != 0 && options.Limit < len(results) {
|
if options.Limit != 0 {
|
||||||
|
limit = len(results)
|
||||||
|
if options.Limit < len(results) {
|
||||||
limit = options.Limit
|
limit = options.Limit
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paramsArr := []SearchResult{}
|
paramsArr := []SearchResult{}
|
||||||
for i := 0; i < limit; i++ {
|
for i := 0; i < limit; i++ {
|
||||||
|
@ -118,10 +118,20 @@ registries = ['{{.Host}}:{{.Port}}']`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search limit flag", func() {
|
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()
|
search.WaitWithDefaultTimeout()
|
||||||
Expect(search.ExitCode()).To(Equal(0))
|
Expect(search.ExitCode()).To(Equal(0))
|
||||||
Expect(len(search.OutputToStringArray())).To(Equal(4))
|
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() {
|
It("podman search with filter stars", func() {
|
||||||
|
Reference in New Issue
Block a user