From ec655579da0192d785bf9c99e4a9946deee4c555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 29 Sep 2023 11:03:17 +0200 Subject: [PATCH] util/resolver: Fix insecure mirrors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors in `RegistryConfig.Mirrors` can be specified using a full URL (schema, trailing slashes) but registries in the input map are keyed by their hostname. Previous code used the mirror URL as key which resulted in an empty `RegistryConfig` being passed to the `fillInsecureOpts` function and didn't set the insecure options. Use Host part of the parsed registry as a key instead. Signed-off-by: Paweł Gronowski --- util/resolver/resolver.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/resolver/resolver.go b/util/resolver/resolver.go index 0abe597e0843..a0276ddb775e 100644 --- a/util/resolver/resolver.go +++ b/util/resolver/resolver.go @@ -130,9 +130,10 @@ func NewRegistryConfig(m map[string]config.RegistryConfig) docker.RegistryHosts var out []docker.RegistryHost - for _, mirror := range c.Mirrors { - h := newMirrorRegistryHost(mirror) - hosts, err := fillInsecureOpts(mirror, m[mirror], h) + for _, rawMirror := range c.Mirrors { + h := newMirrorRegistryHost(rawMirror) + mirrorHost := h.Host + hosts, err := fillInsecureOpts(mirrorHost, m[mirrorHost], h) if err != nil { return nil, err }