summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-06-16 14:06:55 +0200
committerValentin Rothberg <rothberg@redhat.com>2020-06-19 14:47:36 +0200
commitb05888a97dbb45a205ff535538ecdd91a19c6ae3 (patch)
tree7fdfa0188f2d7c27029deb50097a71b17d3b744b /libpod/image
parent5ec29f8d4e79500915ec79824d9eb21630205f3f (diff)
downloadpodman-b05888a97dbb45a205ff535538ecdd91a19c6ae3.tar.gz
podman-b05888a97dbb45a205ff535538ecdd91a19c6ae3.tar.bz2
podman-b05888a97dbb45a205ff535538ecdd91a19c6ae3.zip
search: allow wildcards
Allow wildcards in the search term. Note that not all registries support wildcards and it may only work with v1 registries. Note that searching implies figuring out if the specified search term includes a registry. If there's not registry detected, the search term will be used against all configured "unqualified-serach-registries" in the registries.conf. The parsing logic considers a registry to be the substring before the first slash `/`. With these changes we now not only support wildcards but arbitrary input; ultimately it's up to the registries to decide whether they support given input or not. Fixes: bugzilla.redhat.com/show_bug.cgi?id=1846629 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/search.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/libpod/image/search.go b/libpod/image/search.go
index f8d45d576..72dba668f 100644
--- a/libpod/image/search.go
+++ b/libpod/image/search.go
@@ -64,13 +64,16 @@ type SearchFilter struct {
// SearchImages searches images based on term and the specified SearchOptions
// in all registries.
func SearchImages(term string, options SearchOptions) ([]SearchResult, error) {
- // Check if search term has a registry in it
- registry, err := sysreg.GetRegistry(term)
- if err != nil {
- return nil, errors.Wrapf(err, "error getting registry from %q", term)
- }
- if registry != "" {
- term = term[len(registry)+1:]
+ registry := ""
+
+ // Try to extract a registry from the specified search term. We
+ // consider everything before the first slash to be the registry. Note
+ // that we cannot use the reference parser from the containers/image
+ // library as the search term may container arbitrary input such as
+ // wildcards. See bugzilla.redhat.com/show_bug.cgi?id=1846629.
+ if spl := strings.SplitN(term, "/", 2); len(spl) > 1 {
+ registry = spl[0]
+ term = spl[1]
}
registries, err := getRegistries(registry)