(ctx context.Context, hostname string)
| 8 | ) |
| 9 | |
| 10 | func (s *Service) Endpoints(ctx context.Context, hostname string) ([]APIEndpoint, error) { |
| 11 | if hostname == DefaultNamespace || hostname == IndexHostname { |
| 12 | return []APIEndpoint{{ |
| 13 | URL: DefaultV2Registry, |
| 14 | TLSConfig: tlsconfig.ServerDefault(), |
| 15 | }}, nil |
| 16 | } |
| 17 | |
| 18 | tlsConfig, err := newTLSConfig(ctx, hostname, s.config.isSecureIndex(hostname)) |
| 19 | if err != nil { |
| 20 | return nil, err |
| 21 | } |
| 22 | |
| 23 | endpoints := []APIEndpoint{{ |
| 24 | URL: &url.URL{Scheme: "https", Host: hostname}, |
| 25 | TLSConfig: tlsConfig, |
| 26 | }} |
| 27 | |
| 28 | if tlsConfig.InsecureSkipVerify { |
| 29 | endpoints = append(endpoints, APIEndpoint{ |
| 30 | URL: &url.URL{Scheme: "http", Host: hostname}, |
| 31 | // used to check if supposed to be secure via InsecureSkipVerify |
| 32 | TLSConfig: tlsConfig, |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | return endpoints, nil |
| 37 | } |
no test coverage detected