Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions cli/config/configfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,12 @@ func decodeAuth(authStr string) (string, string, error) {
// GetCredentialsStore returns a new credentials store from the settings in the
// configuration file
func (c *ConfigFile) GetCredentialsStore(registryHostname string) credentials.Store {
store := credentials.NewFileStore(c)

if helper := getConfiguredCredentialStore(c, getAuthConfigKey(registryHostname)); helper != "" {
var store credentials.Store
acKey := getAuthConfigKey(registryHostname)
if helper, ok := c.CredentialHelpers[acKey]; ok && helper != "" {
store = newNativeStore(c, helper)
} else {
store = credentials.NewFileStore(c)
}

envConfig := os.Getenv(DockerEnvConfigKey)
Expand Down Expand Up @@ -390,18 +392,6 @@ func (c *ConfigFile) GetAuthConfig(registryHostname string) (types.AuthConfig, e
return c.GetCredentialsStore(acKey).Get(acKey)
}

// getConfiguredCredentialStore returns the credential helper configured for the
// given registry, the default credsStore, or the empty string if neither are
// configured.
func getConfiguredCredentialStore(c *ConfigFile, registryHostname string) string {
if c.CredentialHelpers != nil && registryHostname != "" {
if helper, exists := c.CredentialHelpers[registryHostname]; exists {
return helper
}
}
return c.CredentialsStore
}

// GetAllCredentials returns all of the credentials stored in all of the
// configured credential stores.
func (c *ConfigFile) GetAllCredentials() (map[string]types.AuthConfig, error) {
Expand Down
Loading