func registryEndpoints(config Registry, host string) ([]string, error) {
	var endpoints []string
	_, ok := config.Mirrors[host]
	if ok {
		endpoints = config.Mirrors[host].Endpoints
	} else {
		endpoints = config.Mirrors["*"].Endpoints
	}
	defaultHost, err := docker.DefaultHost(host)
	if err != nil {
		return nil, errors.Wrap(err, "get default host")
	}
	for i := range endpoints {
		en, err := addDefaultScheme(endpoints[i])
		if err != nil {
			return nil, errors.Wrap(err, "parse endpoint url")
		}
		endpoints[i] = en
	}
	for _, e := range endpoints {
		u, err := url.Parse(e)
		if err != nil {
			return nil, errors.Wrap(err, "parse endpoint url")
		}
		if u.Host == host {
			// Do not add default if the endpoint already exists.
			return endpoints, nil
		}
	}
	return append(endpoints, defaultScheme(defaultHost)+"://"+defaultHost), nil
}
// 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 `*`.
// Ported from https://github.com/containerd/containerd/blob/v1.5.2/pkg/cri/server/image_pull.go#L431-L464
// TODO: import this from CRI package once we drop support to continerd v1.4.x
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 `*`.
// 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 ` * ` . // Ported from https : // github . com / containerd / containerd / blob / v1 . 5 . 2 / pkg / cri / server / image_pull . go#L431 - L464 // TODO : import this from CRI package once we drop support to continerd v1 . 4 . x
func registryEndpoints(config Registry, host string) ([]string, error) {
	var endpoints []string
	_, ok := config.Mirrors[host]
	if ok {
		endpoints = config.Mirrors[host].Endpoints
	} else {
		endpoints = config.Mirrors["*"].Endpoints
	}
	defaultHost, err := docker.DefaultHost(host)
	if err != nil {
		return nil, errors.Wrap(err, "get default host")
	}
	for i := range endpoints {
		en, err := addDefaultScheme(endpoints[i])
		if err != nil {
			return nil, errors.Wrap(err, "parse endpoint url")
		}
		endpoints[i] = en
	}
	for _, e := range endpoints {
		u, err := url.Parse(e)
		if err != nil {
			return nil, errors.Wrap(err, "parse endpoint url")
		}
		if u.Host == host {
			return endpoints, nil
		}
	}
	return append(endpoints, defaultScheme(defaultHost)+"://"+defaultHost), nil
}
func registryEndpoints ( config Registry , host string ) ( [ ] string , error ) { var endpoints [ ] string _ , ok := config . Mirrors [ host ] if ok { endpoints = config . Mirrors [ host ] . Endpoints } else { endpoints = config . Mirrors [ " " ] . Endpoints } defaultHost , err := docker . DefaultHost ( host ) if err != nil { return nil , errors . Wrap ( err , " " ) } for i := range endpoints { en , err := addDefaultScheme ( endpoints [ i ] ) if err != nil { return nil , errors . Wrap ( err , " " ) } endpoints [ i ] = en } for _ , e := range endpoints { u , err := url . Parse ( e ) if err != nil { return nil , errors . Wrap ( err , " " ) } if u . Host == host { return endpoints , nil } } return append ( endpoints , defaultScheme ( defaultHost ) + " " + defaultHost ) , nil }
registryEndpoints returns endpoints for a given host.
registryEndpoints returns endpoints for a given host .
// Do not add default if the endpoint already exists.