Merge pull request #4987 from Random-Liu/fix-auth-config-conversion
Fix deprecated registry auth conversion.
This commit is contained in:
commit
ccde82da2b
@ -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
|
||||
|
@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) {
|
||||
},
|
||||
Registry: Registry{
|
||||
Configs: map[string]RegistryConfig{
|
||||
"https://gcr.io": {
|
||||
"gcr.io": {
|
||||
Auth: &AuthConfig{
|
||||
Username: "test",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user