Set default scheme in registryEndpoints for host

Signed-off-by: Erik Wilson <Erik.E.Wilson@gmail.com>
This commit is contained in:
Erik Wilson 2019-10-30 16:10:28 -07:00
parent 73e5fa0f34
commit 7cc3938717

View File

@ -310,10 +310,6 @@ func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHost
config = c.config.Registry.Configs[u.Host] config = c.config.Registry.Configs[u.Host]
) )
if u.Scheme == "" {
u.Scheme = defaultScheme(u.Host)
}
if u.Scheme != "https" && config.TLS != nil { if u.Scheme != "https" && config.TLS != nil {
return nil, errors.Errorf("tls provided for http endpoint %q", e) return nil, errors.Errorf("tls provided for http endpoint %q", e)
} }
@ -355,8 +351,7 @@ func defaultScheme(host string) string {
if h, _, err := net.SplitHostPort(host); err == nil { if h, _, err := net.SplitHostPort(host); err == nil {
host = h host = h
} }
if host == "localhost" || host == "127.0.0.1" || if host == "localhost" || host == "127.0.0.1" || host == "::1" {
host == "::1" {
return "http" return "http"
} }
return "https" return "https"
@ -387,7 +382,7 @@ func (c *criService) registryEndpoints(host string) ([]string, error) {
return endpoints, nil return endpoints, nil
} }
} }
return append(endpoints, "https://"+defaultHost), nil return append(endpoints, defaultScheme(defaultHost)+"://"+defaultHost), nil
} }
// newTransport returns a new HTTP transport used to pull image. // newTransport returns a new HTTP transport used to pull image.