Skip to content

Commit f9f8455

Browse files
committed
Backport containerd#7393 to sbserver
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent 0cbfb33 commit f9f8455

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

pkg/cri/sbserver/image_pull.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
425425
if err != nil {
426426
return nil, fmt.Errorf("get TLSConfig for registry %q: %w", e, err)
427427
}
428-
} else if isLocalHost(host) && u.Scheme == "http" {
428+
} else if docker.IsLocalhost(host) && u.Scheme == "http" {
429429
// Skipping TLS verification for localhost
430430
transport.TLSClientConfig = &tls.Config{
431431
InsecureSkipVerify: true,
@@ -470,26 +470,12 @@ func (c *criService) registryHosts(ctx context.Context, auth *runtime.AuthConfig
470470

471471
// defaultScheme returns the default scheme for a registry host.
472472
func defaultScheme(host string) string {
473-
if isLocalHost(host) {
473+
if docker.IsLocalhost(host) {
474474
return "http"
475475
}
476476
return "https"
477477
}
478478

479-
// isLocalHost checks if the registry host is local.
480-
func isLocalHost(host string) bool {
481-
if h, _, err := net.SplitHostPort(host); err == nil {
482-
host = h
483-
}
484-
485-
if host == "localhost" {
486-
return true
487-
}
488-
489-
ip := net.ParseIP(host)
490-
return ip.IsLoopback()
491-
}
492-
493479
// addDefaultScheme returns the endpoint with default scheme
494480
func addDefaultScheme(endpoint string) (string, error) {
495481
if strings.Contains(endpoint, "://") {

0 commit comments

Comments
 (0)