Merge pull request #4987 from Random-Liu/fix-auth-config-conversion

Fix deprecated registry auth conversion.
This commit is contained in:
Phil Estes 2021-02-03 23:29:13 -05:00 committed by GitHub
commit ccde82da2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) {
},
Registry: Registry{
Configs: map[string]RegistryConfig{
"https://gcr.io": {
"gcr.io": {
Auth: &AuthConfig{
Username: "test",
},