mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
636c276f67
… and refactor a little bit some daemon on the way. - Move `SearchRegistryForImages` to a new file (`daemon/search.go`) as `daemon.go` is getting pretty big. - `registry.Service` is now an interface (allowing us to decouple it a little bit and thus unit test easily). - Add some unit test for `SearchRegistryForImages`. - Use UniqueExactMatch for search filters - And use empty restore id for now in client.ContainerStart. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package registry
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
"github.com/docker/go-connections/tlsconfig"
|
|
)
|
|
|
|
func (s *DefaultService) lookupV1Endpoints(hostname string) (endpoints []APIEndpoint, err error) {
|
|
var cfg = tlsconfig.ServerDefault
|
|
tlsConfig := &cfg
|
|
if hostname == DefaultNamespace {
|
|
endpoints = append(endpoints, APIEndpoint{
|
|
URL: DefaultV1Registry,
|
|
Version: APIVersion1,
|
|
Official: true,
|
|
TrimHostname: true,
|
|
TLSConfig: tlsConfig,
|
|
})
|
|
return endpoints, nil
|
|
}
|
|
|
|
tlsConfig, err = s.TLSConfig(hostname)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
endpoints = []APIEndpoint{
|
|
{
|
|
URL: &url.URL{
|
|
Scheme: "https",
|
|
Host: hostname,
|
|
},
|
|
Version: APIVersion1,
|
|
TrimHostname: true,
|
|
TLSConfig: tlsConfig,
|
|
},
|
|
}
|
|
|
|
if tlsConfig.InsecureSkipVerify {
|
|
endpoints = append(endpoints, APIEndpoint{ // or this
|
|
URL: &url.URL{
|
|
Scheme: "http",
|
|
Host: hostname,
|
|
},
|
|
Version: APIVersion1,
|
|
TrimHostname: true,
|
|
// used to check if supposed to be secure via InsecureSkipVerify
|
|
TLSConfig: tlsConfig,
|
|
})
|
|
}
|
|
return endpoints, nil
|
|
}
|