summaryrefslogtreecommitdiff
path: root/registry/service_v2.go
diff options
context:
space:
mode:
authorhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:30:55 +0900
committerhwajeong.son <hwajeong.son@samsung.com>2018-08-20 13:30:55 +0900
commit0b51891e5977b87f986f4db2cbbe09295cfdbedc (patch)
treec35ac732cb1dffccee5a32131431f753481077c2 /registry/service_v2.go
parenteea0e89806b2cf59af3dccabc67014bd19b91b82 (diff)
downloaddocker-engine-master.tar.gz
docker-engine-master.tar.bz2
docker-engine-master.zip
Signed-off-by: hwajeong.son <hwajeong.son@samsung.com>
Diffstat (limited to 'registry/service_v2.go')
-rw-r--r--registry/service_v2.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/registry/service_v2.go b/registry/service_v2.go
new file mode 100644
index 0000000..68466f8
--- /dev/null
+++ b/registry/service_v2.go
@@ -0,0 +1,82 @@
+package registry
+
+import (
+ "net/url"
+ "strings"
+
+ "github.com/docker/go-connections/tlsconfig"
+)
+
+func (s *DefaultService) lookupV2Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
+ tlsConfig := tlsconfig.ServerDefault()
+ if hostname == DefaultNamespace || hostname == IndexHostname {
+ // v2 mirrors
+ for _, mirror := range s.config.Mirrors {
+ if !strings.HasPrefix(mirror, "http://") && !strings.HasPrefix(mirror, "https://") {
+ mirror = "https://" + mirror
+ }
+ mirrorURL, err := url.Parse(mirror)
+ if err != nil {
+ return nil, err
+ }
+ mirrorTLSConfig, err := s.tlsConfigForMirror(mirrorURL)
+ if err != nil {
+ return nil, err
+ }
+ endpoints = append(endpoints, APIEndpoint{
+ URL: mirrorURL,
+ // guess mirrors are v2
+ Version: APIVersion2,
+ Mirror: true,
+ TrimHostname: true,
+ TLSConfig: mirrorTLSConfig,
+ })
+ }
+ // v2 registry
+ endpoints = append(endpoints, APIEndpoint{
+ URL: DefaultV2Registry,
+ Version: APIVersion2,
+ Official: true,
+ TrimHostname: true,
+ TLSConfig: tlsConfig,
+ })
+
+ return endpoints, nil
+ }
+
+ ana := allowNondistributableArtifacts(s.config, hostname)
+
+ tlsConfig, err = s.tlsConfig(hostname)
+ if err != nil {
+ return nil, err
+ }
+
+ endpoints = []APIEndpoint{
+ {
+ URL: &url.URL{
+ Scheme: "https",
+ Host: hostname,
+ },
+ Version: APIVersion2,
+ AllowNondistributableArtifacts: ana,
+ TrimHostname: true,
+ TLSConfig: tlsConfig,
+ },
+ }
+
+ if tlsConfig.InsecureSkipVerify {
+ endpoints = append(endpoints, APIEndpoint{
+ URL: &url.URL{
+ Scheme: "http",
+ Host: hostname,
+ },
+ Version: APIVersion2,
+ AllowNondistributableArtifacts: ana,
+ TrimHostname: true,
+ // used to check if supposed to be secure via InsecureSkipVerify
+ TLSConfig: tlsConfig,
+ })
+ }
+
+ return endpoints, nil
+}