summaryrefslogtreecommitdiff
path: root/cmd/podman/search.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-06-27 13:37:56 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-06-28 16:55:29 +0000
commit3b9046a170119c9d3e2975f03587776842c126ec (patch)
treea3bd0c122de2d99a08c1c909c95fbd91bbcb1fa1 /cmd/podman/search.go
parent650797c0162b52956433dd0c92210b65ab93acd3 (diff)
downloadpodman-3b9046a170119c9d3e2975f03587776842c126ec.tar.gz
podman-3b9046a170119c9d3e2975f03587776842c126ec.tar.bz2
podman-3b9046a170119c9d3e2975f03587776842c126ec.zip
Remove the --registry flag from podman search
Instead of setting the --registry flag to search a single registry, prefix the registry before the image name in the input, an example is `podman search registry.fedoraproject.org/fedora` and this will search for the fedora image in only registry.fedoraproject.org. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #1011 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/search.go')
-rw-r--r--cmd/podman/search.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/cmd/podman/search.go b/cmd/podman/search.go
index 064badec8..15dc1df11 100644
--- a/cmd/podman/search.go
+++ b/cmd/podman/search.go
@@ -7,6 +7,7 @@ import (
"strings"
"github.com/containers/image/docker"
+ "github.com/docker/distribution/reference"
"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/formats"
"github.com/projectatomic/libpod/cmd/podman/libpodruntime"
@@ -43,10 +44,6 @@ var (
Name: "no-trunc",
Usage: "do not truncate the output",
},
- cli.StringSliceFlag{
- Name: "registry",
- Usage: "specific registry to search",
- },
cli.BoolTFlag{
Name: "tls-verify",
Usage: "require HTTPS and verify certificates when contacting registries (default: true)",
@@ -98,6 +95,15 @@ func searchCmd(c *cli.Context) error {
}
term := args[0]
+ // Check if search term has a registry in it
+ registry, err := getRegistry(term)
+ if err != nil {
+ return errors.Wrapf(err, "error getting registry from %q", term)
+ }
+ if registry != "" {
+ term = term[len(registry)+1:]
+ }
+
if err := validateFlags(c, searchFlags); err != nil {
return err
}
@@ -116,7 +122,7 @@ func searchCmd(c *cli.Context) error {
filter: c.StringSlice("filter"),
authfile: c.String("authfile"),
}
- regAndSkipTLS, err := getRegistriesAndSkipTLS(c)
+ regAndSkipTLS, err := getRegistriesAndSkipTLS(c, registry)
if err != nil {
return err
}
@@ -158,7 +164,7 @@ func (s *searchParams) headerMap() map[string]string {
}
// A function for finding which registries can skip TLS
-func getRegistriesAndSkipTLS(c *cli.Context) (map[string]bool, error) {
+func getRegistriesAndSkipTLS(c *cli.Context, registry string) (map[string]bool, error) {
// Variables for setting up Registry and TLSVerify
tlsVerify := c.BoolT("tls-verify")
forceSecure := false
@@ -168,8 +174,8 @@ func getRegistriesAndSkipTLS(c *cli.Context) (map[string]bool, error) {
}
var registries []string
- if len(c.StringSlice("registry")) > 0 {
- registries = c.StringSlice("registry")
+ if registry != "" {
+ registries = append(registries, registry)
} else {
var err error
registries, err = sysreg.GetRegistries()
@@ -343,3 +349,11 @@ func matchesOfficialFilter(filter searchFilterParams, result docker.SearchResult
}
return true
}
+
+func getRegistry(image string) (string, error) {
+ imgRef, err := reference.Parse(image)
+ if err != nil {
+ return "", err
+ }
+ return reference.Domain(imgRef.(reference.Named)), nil
+}