diff --git a/pkg/cri/config/config.go b/pkg/cri/config/config.go index 74f828ac1..7c5a20ecf 100644 --- a/pkg/cri/config/config.go +++ b/pkg/cri/config/config.go @@ -18,6 +18,7 @@ package config import ( "context" + "net/url" "time" "github.com/BurntSushi/toml" @@ -353,6 +354,14 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error { } for endpoint, auth := range c.Registry.Auths { auth := auth + u, err := url.Parse(endpoint) + if err != nil { + return errors.Wrapf(err, "failed to parse registry url %q from `registry.auths`", endpoint) + } + if u.Scheme != "" { + // Do not include the scheme in the new registry config. + endpoint = u.Host + } config := c.Registry.Configs[endpoint] config.Auth = &auth c.Registry.Configs[endpoint] = config diff --git a/pkg/cri/config/config_test.go b/pkg/cri/config/config_test.go index 3b544f7b8..ff16284cc 100644 --- a/pkg/cri/config/config_test.go +++ b/pkg/cri/config/config_test.go @@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) { }, Registry: Registry{ Configs: map[string]RegistryConfig{ - "https://gcr.io": { + "gcr.io": { Auth: &AuthConfig{ Username: "test", },