github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/registry/service_v1.go (about)

     1  package registry
     2  
     3  import (
     4  	"net/url"
     5  
     6  	"github.com/docker/go-connections/tlsconfig"
     7  )
     8  
     9  func (s *DefaultService) lookupV1Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
    10  	tlsConfig := tlsconfig.ServerDefault()
    11  	if hostname == DefaultNamespace {
    12  		endpoints = append(endpoints, APIEndpoint{
    13  			URL:          DefaultV1Registry,
    14  			Version:      APIVersion1,
    15  			Official:     true,
    16  			TrimHostname: true,
    17  			TLSConfig:    tlsConfig,
    18  		})
    19  		return endpoints, nil
    20  	}
    21  
    22  	tlsConfig, err = s.tlsConfig(hostname)
    23  	if err != nil {
    24  		return nil, err
    25  	}
    26  
    27  	endpoints = []APIEndpoint{
    28  		{
    29  			URL: &url.URL{
    30  				Scheme: "https",
    31  				Host:   hostname,
    32  			},
    33  			Version:      APIVersion1,
    34  			TrimHostname: true,
    35  			TLSConfig:    tlsConfig,
    36  		},
    37  	}
    38  
    39  	if tlsConfig.InsecureSkipVerify {
    40  		endpoints = append(endpoints, APIEndpoint{ // or this
    41  			URL: &url.URL{
    42  				Scheme: "http",
    43  				Host:   hostname,
    44  			},
    45  			Version:      APIVersion1,
    46  			TrimHostname: true,
    47  			// used to check if supposed to be secure via InsecureSkipVerify
    48  			TLSConfig: tlsConfig,
    49  		})
    50  	}
    51  	return endpoints, nil
    52  }