Use http
for localhost, 127.0.0.1 and ::1 by default.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -310,6 +310,10 @@ func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHost
|
||||
config = c.config.Registry.Configs[u.Host]
|
||||
)
|
||||
|
||||
if u.Scheme == "" {
|
||||
u.Scheme = defaultScheme(u.Host)
|
||||
}
|
||||
|
||||
if u.Scheme != "https" && config.TLS != nil {
|
||||
return nil, errors.Errorf("tls provided for http endpoint %q", e)
|
||||
}
|
||||
@@ -346,6 +350,18 @@ func (c *criService) registryHosts(auth *runtime.AuthConfig) docker.RegistryHost
|
||||
}
|
||||
}
|
||||
|
||||
// defaultScheme returns the default scheme for a registry host.
|
||||
func defaultScheme(host string) string {
|
||||
if h, _, err := net.SplitHostPort(host); err == nil {
|
||||
host = h
|
||||
}
|
||||
if host == "localhost" || host == "127.0.0.1" ||
|
||||
host == "::1" {
|
||||
return "http"
|
||||
}
|
||||
return "https"
|
||||
}
|
||||
|
||||
// registryEndpoints returns endpoints for a given host.
|
||||
// It adds default registry endpoint if it does not exist in the passed-in endpoint list.
|
||||
// It also supports wildcard host matching with `*`.
|
||||
|
Reference in New Issue
Block a user