summaryrefslogtreecommitdiff
path: root/pkg/registries/registries.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-05-03 09:34:34 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2019-05-03 10:38:51 -0400
commitd1a7378aa06eb3cc6ff02c3ca90356bf9a151ada (patch)
tree787422cac8ab499ca8c26aa679558ddb96f4d7e8 /pkg/registries/registries.go
parentd9d9c82184ad6d7e3fad07dfe2e99b158560d3a8 (diff)
downloadpodman-d1a7378aa06eb3cc6ff02c3ca90356bf9a151ada.tar.gz
podman-d1a7378aa06eb3cc6ff02c3ca90356bf9a151ada.tar.bz2
podman-d1a7378aa06eb3cc6ff02c3ca90356bf9a151ada.zip
change from sysregistries to sysregistriesv2
We want to start supporting the registries.conf format. Also start showing blocked registries in podman info Fix sorting so all registries are listed together in podman info. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/registries/registries.go')
-rw-r--r--pkg/registries/registries.go49
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