-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathservice_v2.go
More file actions
37 lines (30 loc) · 859 Bytes
/
service_v2.go
File metadata and controls
37 lines (30 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
}