Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search registries with an empty query #1444

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/podman/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 25 additions & 2 deletions docs/podman-search.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]**

Expand Down Expand Up @@ -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`)
Expand Down
9 changes: 8 additions & 1 deletion test/e2e/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"})
Expand Down
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ github.com/containerd/cgroups 58556f5ad8448d99a6f7bea69ea4bdb7747cfeb0
github.com/containerd/continuity master
github.com/containernetworking/cni v0.7.0-alpha1
github.com/containernetworking/plugins 1562a1e60ed101aacc5e08ed9dbeba8e9f3d4ec1
github.com/containers/image 5df44e095ed826fbe2beeaabb329c749d7d6c3b6
github.com/containers/image d8b5cf2b804a48489e5203d51254ef576794049d
github.com/containers/storage 243c4cd616afdf06b4a975f18c4db083d26b1641
github.com/containers/psgo 5dde6da0bc8831b35243a847625bcf18183bd1ee
github.com/coreos/go-systemd v14
Expand Down
87 changes: 52 additions & 35 deletions vendor/github.com/containers/image/docker/docker_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/containers/image/ostree/ostree_dest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.