Refactor ResolveAuthConfig to remove the builder dependency on cli code.

registry.ResolveAuthConfig() only needs the AuthConfigs from the ConfigFile, so
this change passed just the AuthConfigs.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin
2015-12-11 19:11:20 -08:00
parent 00cca12e77
commit f7bb65ca8b
2 changed files with 19 additions and 46 deletions

View File

@@ -221,10 +221,10 @@ func tryV2TokenAuthLogin(authConfig *cliconfig.AuthConfig, params map[string]str
}
// ResolveAuthConfig matches an auth configuration to a server address or a URL
func ResolveAuthConfig(config *cliconfig.ConfigFile, index *IndexInfo) cliconfig.AuthConfig {
func ResolveAuthConfig(authConfigs map[string]cliconfig.AuthConfig, index *IndexInfo) cliconfig.AuthConfig {
configKey := index.GetAuthConfigKey()
// First try the happy case
if c, found := config.AuthConfigs[configKey]; found || index.Official {
if c, found := authConfigs[configKey]; found || index.Official {
return c
}
@@ -243,7 +243,7 @@ func ResolveAuthConfig(config *cliconfig.ConfigFile, index *IndexInfo) cliconfig
// Maybe they have a legacy config file, we will iterate the keys converting
// them to the new format and testing
for registry, ac := range config.AuthConfigs {
for registry, ac := range authConfigs {
if configKey == convertToHostname(registry) {
return ac
}