daemon/RegistryHosts: Don't lose mirrors

`docker.io` is present in the `IndexConfigs` so the `Mirrors` property
would get lost because a fresh `RegistryConfig` object was created.

Instead of creating a new object, reuse the existing one and just
mutate its fields.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-09-29 10:54:02 +02:00
parent a67b7554c8
commit d871a665de
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -196,7 +196,7 @@ func (daemon *Daemon) RegistryHosts(host string) ([]docker.RegistryHost, error)
}
conf := daemon.registryService.ServiceConfig().IndexConfigs
for k, v := range conf {
c := resolverconfig.RegistryConfig{}
c := m[k]
if !v.Secure {
t := true
c.PlainHTTP = &t
@ -204,8 +204,7 @@ func (daemon *Daemon) RegistryHosts(host string) ([]docker.RegistryHost, error)
}
m[k] = c
}
if _, ok := m[host]; !ok && daemon.registryService.IsInsecureRegistry(host) {
c := resolverconfig.RegistryConfig{}
if c, ok := m[host]; !ok && daemon.registryService.IsInsecureRegistry(host) {
t := true
c.PlainHTTP = &t
c.Insecure = &t