Backport #7393 to sbserver
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
0cbfb3375f
commit
f9f8455332
@ -425,7 +425,7 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get TLSConfig for registry %q: %w", e, err)
|
return nil, fmt.Errorf("get TLSConfig for registry %q: %w", e, err)
|
||||||
}
|
}
|
||||||
} else if isLocalHost(host) && u.Scheme == "http" {
|
} else if docker.IsLocalhost(host) && u.Scheme == "http" {
|
||||||
// Skipping TLS verification for localhost
|
// Skipping TLS verification for localhost
|
||||||
transport.TLSClientConfig = &tls.Config{
|
transport.TLSClientConfig = &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
@ -470,26 +470,12 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
|
|||||||
|
|
||||||
// defaultScheme returns the default scheme for a registry host.
|
// defaultScheme returns the default scheme for a registry host.
|
||||||
func defaultScheme(host string) string {
|
func defaultScheme(host string) string {
|
||||||
if isLocalHost(host) {
|
if docker.IsLocalhost(host) {
|
||||||
return "http"
|
return "http"
|
||||||
}
|
}
|
||||||
return "https"
|
return "https"
|
||||||
}
|
}
|
||||||
|
|
||||||
// isLocalHost checks if the registry host is local.
|
|
||||||
func isLocalHost(host string) bool {
|
|
||||||
if h, _, err := net.SplitHostPort(host); err == nil {
|
|
||||||
host = h
|
|
||||||
}
|
|
||||||
|
|
||||||
if host == "localhost" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
ip := net.ParseIP(host)
|
|
||||||
return ip.IsLoopback()
|
|
||||||
}
|
|
||||||
|
|
||||||
// addDefaultScheme returns the endpoint with default scheme
|
// addDefaultScheme returns the endpoint with default scheme
|
||||||
func addDefaultScheme(endpoint string) (string, error) {
|
func addDefaultScheme(endpoint string) (string, error) {
|
||||||
if strings.Contains(endpoint, "://") {
|
if strings.Contains(endpoint, "://") {
|
||||||
|
Loading…
Reference in New Issue
Block a user