summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2018-09-11 16:37:43 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-13 16:20:40 +0000
commit70b160ae032b548b3d4456f17f8436b24ea37a15 (patch)
treec9fd9529573742180ca9d582fe68349d04ca96f3
parent9bc3c9d11cb112410e963b73a4d0dfe3742d27cf (diff)
downloadpodman-70b160ae032b548b3d4456f17f8436b24ea37a15.tar.gz
podman-70b160ae032b548b3d4456f17f8436b24ea37a15.tar.bz2
podman-70b160ae032b548b3d4456f17f8436b24ea37a15.zip
Search registries with an empty query
Adds functionality to search registries implementing the v2 endpoint with an empty query, that is the results will be all the available images on the registries. If this is tried with a v1 registry an error will occur. To search a whole registry, there needs to be a trailing slash at the end, i.e `podman search registry.fedoraproject.org/`. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com> Closes: #1444 Approved by: rhatdan
-rw-r--r--cmd/podman/search.go5
-rw-r--r--docs/podman-search.1.md27
-rw-r--r--test/e2e/search_test.go9
3 files changed, 38 insertions, 3 deletions
diff --git a/cmd/podman/search.go b/cmd/podman/search.go
index 009ff8ba9..f64b822fc 100644
--- a/cmd/podman/search.go
+++ b/cmd/podman/search.go
@@ -345,6 +345,11 @@ func matchesOfficialFilter(filter searchFilterParams, result docker.SearchResult
}
func getRegistry(image string) (string, error) {
+ // It is possible to only have the registry name in the format "myregistry/"
+ // if so, just trim the "/" from the end and return the registry name
+ if strings.HasSuffix(image, "/") {
+ return strings.TrimSuffix(image, "/"), nil
+ }
imgRef, err := reference.Parse(image)
if err != nil {
return "", err
diff --git a/docs/podman-search.1.md b/docs/podman-search.1.md
index 9cc9e1e6b..429c3c5ad 100644
--- a/docs/podman-search.1.md
+++ b/docs/podman-search.1.md
@@ -10,10 +10,12 @@ podman\-search - Search a registry for an image
**podman search** searches a registry or a list of registries for a matching 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
-**registires.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
is being searched, the limit will be applied to each registry. The output can be filtered
-using the **--filter** flag.
+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.
**podman [GLOBAL OPTIONS]**
@@ -116,6 +118,27 @@ INDEX NAME
fedoraproject.org fedoraproject.org/fedora
fedoraproject.org fedoraproject.org/fedora-minimal
```
+
+```
+$ podman search registry.fedoraproject.org/
+INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
+fedoraproject.org registry.fedoraproject.org/f25/cockpit 0
+fedoraproject.org registry.fedoraproject.org/f25/container-engine 0
+fedoraproject.org registry.fedoraproject.org/f25/docker 0
+fedoraproject.org registry.fedoraproject.org/f25/etcd 0
+fedoraproject.org registry.fedoraproject.org/f25/flannel 0
+fedoraproject.org registry.fedoraproject.org/f25/httpd 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-apiserver 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-controller-manager 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-kubelet 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-master 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-node 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-proxy 0
+fedoraproject.org registry.fedoraproject.org/f25/kubernetes-scheduler 0
+fedoraproject.org registry.fedoraproject.org/f25/mariadb 0
+```
+Note: This works only with registries that implement the v2 API. If tried with a v1 registry an error will be returned.
+
## FILES
**registries.conf** (`/etc/containers/registries.conf`)
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go
index 7b9612a35..2c85ca765 100644
--- a/test/e2e/search_test.go
+++ b/test/e2e/search_test.go
@@ -84,7 +84,7 @@ var _ = Describe("Podman search", func() {
})
It("podman search limit flag", func() {
- search := podmanTest.Podman([]string{"search", "--limit", "3", "alpine"})
+ 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))
@@ -120,6 +120,13 @@ var _ = Describe("Podman search", func() {
}
})
+ It("podman search v2 registry with empty query", func() {
+ search := podmanTest.Podman([]string{"search", "registry.fedoraproject.org/"})
+ search.WaitWithDefaultTimeout()
+ Expect(search.ExitCode()).To(Equal(0))
+ Expect(len(search.OutputToStringArray())).To(BeNumerically(">=", 1))
+ })
+
It("podman search attempts HTTP if tls-verify flag is set false", func() {
podmanTest.RestoreArtifact(registry)
fakereg := podmanTest.Podman([]string{"run", "-d", "--name", "registry", "-p", "5000:5000", registry, "/entrypoint.sh", "/etc/docker/registry/config.yml"})