summaryrefslogtreecommitdiff
path: root/pkg/registries/registries.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-04-16 13:39:00 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-18 14:07:59 +0000
commit313e5e83e92f68349d2026fc3f358f237fe93a4a (patch)
tree91c523b44bb8f55790037a9a7b42bf63e3c90de6 /pkg/registries/registries.go
parent982927468c6102cfc52e838be4815d2f89d3827e (diff)
downloadpodman-313e5e83e92f68349d2026fc3f358f237fe93a4a.tar.gz
podman-313e5e83e92f68349d2026fc3f358f237fe93a4a.tar.bz2
podman-313e5e83e92f68349d2026fc3f358f237fe93a4a.zip
regression: tls verify should be set on registries.conf if insecure
In the case where podman needs to pull an image, if that registry that the image resides on is known to be insesure (as defined in /etc/containers/registries.conf), tls-verify should be altered on the fly. Signed-off-by: baude <bbaude@redhat.com> Closes: #626 Approved by: mheon
Diffstat (limited to 'pkg/registries/registries.go')
-rw-r--r--pkg/registries/registries.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go
new file mode 100644
index 000000000..8e43c8b91
--- /dev/null
+++ b/pkg/registries/registries.go
@@ -0,0 +1,37 @@
+package registries
+
+import (
+ "os"
+
+ "github.com/containers/image/pkg/sysregistries"
+ "github.com/containers/image/types"
+ "github.com/pkg/errors"
+)
+
+// GetRegistries obtains the list of registries defined in the global registries file.
+func GetRegistries() ([]string, error) {
+ registryConfigPath := ""
+ envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
+ if len(envOverride) > 0 {
+ registryConfigPath = envOverride
+ }
+ searchRegistries, err := sysregistries.GetRegistries(&types.SystemContext{SystemRegistriesConfPath: registryConfigPath})
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
+ }
+ return searchRegistries, nil
+}
+
+// GetInsecureRegistries obtains the list of inseure registries from the global registration file.
+func GetInsecureRegistries() ([]string, error) {
+ registryConfigPath := ""
+ envOverride := os.Getenv("REGISTRIES_CONFIG_PATH")
+ if len(envOverride) > 0 {
+ registryConfigPath = envOverride
+ }
+ registries, err := sysregistries.GetInsecureRegistries(&types.SystemContext{SystemRegistriesConfPath: registryConfigPath})
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to parse the registries.conf file")
+ }
+ return registries, nil
+}