1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00
Files
cli/internal/registry/service_v2.go
Sebastiaan van Stijn 5322affc9f internal/registry: remove duplicate endpoint methods
now that we no longer need to account for mirrors, these were
identical, so just use a single one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-24 23:23:11 +02:00

38 lines
859 B
Go

package registry
import (
"context"
"net/url"
"github.com/docker/go-connections/tlsconfig"
)
func (s *Service) Endpoints(ctx context.Context, hostname string) ([]APIEndpoint, error) {
if hostname == DefaultNamespace || hostname == IndexHostname {
return []APIEndpoint{{
URL: DefaultV2Registry,
TLSConfig: tlsconfig.ServerDefault(),
}}, nil
}
tlsConfig, err := newTLSConfig(ctx, hostname, s.config.isSecureIndex(hostname))
if err != nil {
return nil, err
}
endpoints := []APIEndpoint{{
URL: &url.URL{Scheme: "https", Host: hostname},
TLSConfig: tlsConfig,
}}
if tlsConfig.InsecureSkipVerify {
endpoints = append(endpoints, APIEndpoint{
URL: &url.URL{Scheme: "http", Host: hostname},
// used to check if supposed to be secure via InsecureSkipVerify
TLSConfig: tlsConfig,
})
}
return endpoints, nil
}