Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit b4b894c

Browse files
authored
Merge pull request #1621 from zhsj/bpo-containerd-4987
[release/1.4] Fix deprecated registry auth conversion
2 parents 4dbbd50 + 7efa54f commit b4b894c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

pkg/config/config.go

Lines changed: 10 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"
@@ -352,6 +353,15 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
352353
c.Registry.Configs = make(map[string]RegistryConfig)
353354
}
354355
for endpoint, auth := range c.Registry.Auths {
356+
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+
}
355365
config := c.Registry.Configs[endpoint]
356366
config.Auth = &auth
357367
c.Registry.Configs[endpoint] = config

pkg/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)