Skip to content

Commit ccde82d

Browse files
authored
Merge pull request #4987 from Random-Liu/fix-auth-config-conversion
Fix deprecated registry auth conversion.
2 parents 4054230 + b5bf1fd commit ccde82d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/cri/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package config
1818

1919
import (
2020
"context"
21+
"net/url"
2122
"time"
2223

2324
"github.com/BurntSushi/toml"
@@ -353,6 +354,14 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
353354
}
354355
for endpoint, auth := range c.Registry.Auths {
355356
auth := auth
357+
u, err := url.Parse(endpoint)
358+
if err != nil {
359+
return errors.Wrapf(err, "failed to parse registry url %q from `registry.auths`", endpoint)
360+
}
361+
if u.Scheme != "" {
362+
// Do not include the scheme in the new registry config.
363+
endpoint = u.Host
364+
}
356365
config := c.Registry.Configs[endpoint]
357366
config.Auth = &auth
358367
c.Registry.Configs[endpoint] = config

pkg/cri/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) {
294294
},
295295
Registry: Registry{
296296
Configs: map[string]RegistryConfig{
297-
"https://gcr.io": {
297+
"gcr.io": {
298298
Auth: &AuthConfig{
299299
Username: "test",
300300
},

0 commit comments

Comments
 (0)