Skip to content

Commit

Permalink
Merge pull request #4987 from Random-Liu/fix-auth-config-conversion
Browse files Browse the repository at this point in the history
Fix deprecated registry auth conversion.
  • Loading branch information
estesp committed Feb 4, 2021
2 parents 4054230 + b5bf1fd commit ccde82d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/cri/config/config.go
Expand Up @@ -18,6 +18,7 @@ package config

import (
"context"
"net/url"
"time"

"github.com/BurntSushi/toml"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/config/config_test.go
Expand Up @@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) {
},
Registry: Registry{
Configs: map[string]RegistryConfig{
"https://gcr.io": {
"gcr.io": {
Auth: &AuthConfig{
Username: "test",
},
Expand Down

0 comments on commit ccde82d

Please sign in to comment.