github.com/fntlnz/docker@v1.9.0-rc3/registry/service_v1.go (about) 1 package registry 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/docker/docker/pkg/tlsconfig" 8 ) 9 10 func (s *Service) lookupV1Endpoints(repoName string) (endpoints []APIEndpoint, err error) { 11 var cfg = tlsconfig.ServerDefault 12 tlsConfig := &cfg 13 if strings.HasPrefix(repoName, DefaultNamespace+"/") { 14 endpoints = append(endpoints, APIEndpoint{ 15 URL: DefaultV1Registry, 16 Version: APIVersion1, 17 Official: true, 18 TrimHostname: true, 19 TLSConfig: tlsConfig, 20 }) 21 return endpoints, nil 22 } 23 24 slashIndex := strings.IndexRune(repoName, '/') 25 if slashIndex <= 0 { 26 return nil, fmt.Errorf("invalid repo name: missing '/': %s", repoName) 27 } 28 hostname := repoName[:slashIndex] 29 30 tlsConfig, err = s.TLSConfig(hostname) 31 if err != nil { 32 return nil, err 33 } 34 35 endpoints = []APIEndpoint{ 36 { 37 URL: "https://" + hostname, 38 Version: APIVersion1, 39 TrimHostname: true, 40 TLSConfig: tlsConfig, 41 }, 42 } 43 44 if tlsConfig.InsecureSkipVerify { 45 endpoints = append(endpoints, APIEndpoint{ // or this 46 URL: "http://" + hostname, 47 Version: APIVersion1, 48 TrimHostname: true, 49 // used to check if supposed to be secure via InsecureSkipVerify 50 TLSConfig: tlsConfig, 51 }) 52 } 53 return endpoints, nil 54 }