diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-05-03 18:46:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 18:46:35 +0200 |
commit | fde0dc2a55b27b24e89100da3c2c9d52044a8208 (patch) | |
tree | 972905f61ed128c6a138741fe25c78f279fbbf25 /pkg | |
parent | 0eaba2d56a48c68e1d08e287a1c9eb5405cc743a (diff) | |
parent | d1a7378aa06eb3cc6ff02c3ca90356bf9a151ada (diff) | |
download | podman-fde0dc2a55b27b24e89100da3c2c9d52044a8208.tar.gz podman-fde0dc2a55b27b24e89100da3c2c9d52044a8208.tar.bz2 podman-fde0dc2a55b27b24e89100da3c2c9d52044a8208.zip |
Merge pull request #3064 from rhatdan/sysregistriesv2
change from sysregistries to sysregistriesv2
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/registries/registries.go | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go index 9f4c94533..fdb7f33c5 100644 --- a/pkg/registries/registries.go +++ b/pkg/registries/registries.go @@ -5,7 +5,7 @@ import ( "path/filepath" "strings" - "github.com/containers/image/pkg/sysregistries" + "github.com/containers/image/pkg/sysregistriesv2" "github.com/containers/image/types" "github.com/containers/libpod/pkg/rootless" "github.com/docker/distribution/reference" @@ -34,22 +34,57 @@ func SystemRegistriesConfPath() string { return "" } -// GetRegistries obtains the list of registries defined in the global registries file. -func GetRegistries() ([]string, error) { - searchRegistries, err := sysregistries.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()}) +func getRegistries() ([]sysregistriesv2.Registry, error) { + registries, err := sysregistriesv2.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()}) if err != nil { return nil, errors.Wrapf(err, "unable to parse the registries.conf file") } + return registries, nil +} + +// GetRegistries obtains the list of search registries defined in the global registries file. +func GetRegistries() ([]string, error) { + var searchRegistries []string + registries, err := getRegistries() + if err != nil { + return nil, err + } + for _, reg := range registries { + if reg.Search { + searchRegistries = append(searchRegistries, reg.URL) + } + } return searchRegistries, nil } +// GetBlockedRegistries obtains the list of blocked registries defined in the global registries file. +func GetBlockedRegistries() ([]string, error) { + var blockedRegistries []string + registries, err := getRegistries() + if err != nil { + return nil, err + } + for _, reg := range registries { + if reg.Blocked { + blockedRegistries = append(blockedRegistries, reg.URL) + } + } + return blockedRegistries, nil +} + // GetInsecureRegistries obtains the list of insecure registries from the global registration file. func GetInsecureRegistries() ([]string, error) { - registries, err := sysregistries.GetInsecureRegistries(&types.SystemContext{SystemRegistriesConfPath: SystemRegistriesConfPath()}) + var insecureRegistries []string + registries, err := getRegistries() if err != nil { - return nil, errors.Wrapf(err, "unable to parse the registries.conf file") + return nil, err } - return registries, nil + for _, reg := range registries { + if reg.Insecure { + insecureRegistries = append(insecureRegistries, reg.URL) + } + } + return insecureRegistries, nil } // GetRegistry returns the registry name from a string if specified |