Skip to content

Commit

Permalink
util/resolver: fillInsecureOpts don't return slice
Browse files Browse the repository at this point in the history
It's no longer needed to return multiple hosts.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
  • Loading branch information
vvoland committed Oct 3, 2023
1 parent 1096d71 commit baf7c09
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions util/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ const (
defaultPath = "/v2"
)

func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHost) ([]docker.RegistryHost, error) {
var hosts []docker.RegistryHost

func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHost) (*docker.RegistryHost, error) {
tc, err := loadTLSConfig(c)
if err != nil {
return nil, err
Expand Down Expand Up @@ -54,24 +52,17 @@ func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHos
Transport: tracing.NewTransport(transport),
}
tc.InsecureSkipVerify = true
hosts = append(hosts, h2)
return &h2, nil
} else if isHTTP {
h2 := h
h2.Scheme = "http"
hosts = append(hosts, h2)
return &h2, nil
}

if len(hosts) == 0 {
transport := newDefaultTransport()
transport.TLSClientConfig = tc

h.Client = &http.Client{
Transport: tracing.NewTransport(transport),
}
hosts = append(hosts, h)
h.Client = &http.Client{
Transport: tracing.NewTransport(httpsTransport),
}

return hosts, nil
return &h, nil
}

func loadTLSConfig(c config.RegistryConfig) (*tls.Config, error) {
Expand Down Expand Up @@ -138,12 +129,12 @@ func NewRegistryConfig(m map[string]config.RegistryConfig) docker.RegistryHosts
for _, rawMirror := range c.Mirrors {
h := newMirrorRegistryHost(rawMirror)
mirrorHost := h.Host
hosts, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h)
host, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h)
if err != nil {
return nil, err
}

out = append(out, hosts...)
out = append(out, *host)
}

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

out = append(out, hosts...)
out = append(out, *hosts)

return out, nil
},
docker.ConfigureDefaultRegistries(
Expand Down

0 comments on commit baf7c09

Please sign in to comment.