aboutsummaryrefslogtreecommitdiff
path: root/pkg/registries/registries.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-18 13:32:54 +0100
committerGitHub <noreply@github.com>2019-02-18 13:32:54 +0100
commite738ef16225395f5f5e4b93ba1a43ae9449ae11b (patch)
tree00c7d016a064a6efdf96d7fbcf5deb5e56ddf9ee /pkg/registries/registries.go
parentf2139a651706b10824a1641a360020d932798827 (diff)
parentb75dcd445848abad89e19f78193046a8de86c641 (diff)
downloadpodman-e738ef16225395f5f5e4b93ba1a43ae9449ae11b.tar.gz
podman-e738ef16225395f5f5e4b93ba1a43ae9449ae11b.tar.bz2
podman-e738ef16225395f5f5e4b93ba1a43ae9449ae11b.zip
Merge pull request #2354 from rhatdan/varlink
Add registry name to fields returned by varlink image search
Diffstat (limited to 'pkg/registries/registries.go')
-rw-r--r--pkg/registries/registries.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go
index cbb8b730c..9f4c94533 100644
--- a/pkg/registries/registries.go
+++ b/pkg/registries/registries.go
@@ -3,10 +3,12 @@ package registries
import (
"os"
"path/filepath"
+ "strings"
"github.com/containers/image/pkg/sysregistries"
"github.com/containers/image/types"
"github.com/containers/libpod/pkg/rootless"
+ "github.com/docker/distribution/reference"
"github.com/pkg/errors"
)
@@ -49,3 +51,17 @@ func GetInsecureRegistries() ([]string, error) {
}
return registries, nil
}
+
+// GetRegistry returns the registry name from a string if specified
+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
+ }
+ return reference.Domain(imgRef.(reference.Named)), nil
+}