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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
@ -353,6 +354,14 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
|
|||||||
}
|
}
|
||||||
for endpoint, auth := range c.Registry.Auths {
|
for endpoint, auth := range c.Registry.Auths {
|
||||||
auth := auth
|
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 := c.Registry.Configs[endpoint]
|
||||||
config.Auth = &auth
|
config.Auth = &auth
|
||||||
c.Registry.Configs[endpoint] = config
|
c.Registry.Configs[endpoint] = config
|
||||||
|
@ -294,7 +294,7 @@ func TestValidateConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Registry: Registry{
|
Registry: Registry{
|
||||||
Configs: map[string]RegistryConfig{
|
Configs: map[string]RegistryConfig{
|
||||||
"https://gcr.io": {
|
"gcr.io": {
|
||||||
Auth: &AuthConfig{
|
Auth: &AuthConfig{
|
||||||
Username: "test",
|
Username: "test",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user