Skip to content

Commit bc12a9c

Browse files
committed
util/resolver: fillInsecureOpts don't return slice
It's no longer needed to return multiple hosts. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit baf7c09) Signed-off-by: Paweł Gronowski <[email protected]>
1 parent b80e5db commit bc12a9c

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

util/resolver/resolver.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ const (
2222
defaultPath = "/v2"
2323
)
2424

25-
func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHost) ([]docker.RegistryHost, error) {
26-
var hosts []docker.RegistryHost
27-
25+
func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHost) (*docker.RegistryHost, error) {
2826
tc, err := loadTLSConfig(c)
2927
if err != nil {
3028
return nil, err
@@ -54,24 +52,17 @@ func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHos
5452
Transport: tracing.NewTransport(transport),
5553
}
5654
tc.InsecureSkipVerify = true
57-
hosts = append(hosts, h2)
55+
return &h2, nil
5856
} else if isHTTP {
5957
h2 := h
6058
h2.Scheme = "http"
61-
hosts = append(hosts, h2)
59+
return &h2, nil
6260
}
6361

64-
if len(hosts) == 0 {
65-
transport := newDefaultTransport()
66-
transport.TLSClientConfig = tc
67-
68-
h.Client = &http.Client{
69-
Transport: tracing.NewTransport(transport),
70-
}
71-
hosts = append(hosts, h)
62+
h.Client = &http.Client{
63+
Transport: tracing.NewTransport(httpsTransport),
7264
}
73-
74-
return hosts, nil
65+
return &h, nil
7566
}
7667

7768
func loadTLSConfig(c config.RegistryConfig) (*tls.Config, error) {
@@ -138,12 +129,12 @@ func NewRegistryConfig(m map[string]config.RegistryConfig) docker.RegistryHosts
138129
for _, rawMirror := range c.Mirrors {
139130
h := newMirrorRegistryHost(rawMirror)
140131
mirrorHost := h.Host
141-
hosts, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h)
132+
host, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h)
142133
if err != nil {
143134
return nil, err
144135
}
145136

146-
out = append(out, hosts...)
137+
out = append(out, *host)
147138
}
148139

149140
if host == "docker.io" {
@@ -163,7 +154,8 @@ func NewRegistryConfig(m map[string]config.RegistryConfig) docker.RegistryHosts
163154
return nil, err
164155
}
165156

166-
out = append(out, hosts...)
157+
out = append(out, *hosts)
158+
167159
return out, nil
168160
},
169161
docker.ConfigureDefaultRegistries(

0 commit comments

Comments
 (0)