Skip to content

Commit 53d8aad

Browse files
committed
cli/config/configfile: inline getConfiguredCredentialStore
It was a premature abstraction; the "nil" check for the map was redundant, making it literally a 1-liner, so just inline it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 4001288 commit 53d8aad

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

cli/config/configfile/file.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,11 @@ func decodeAuth(authStr string) (string, string, error) {
291291
// GetCredentialsStore returns a new credentials store from the settings in the
292292
// configuration file
293293
func (configFile *ConfigFile) GetCredentialsStore(registryHostname string) credentials.Store {
294-
store := credentials.NewFileStore(configFile)
295-
296-
if helper := getConfiguredCredentialStore(configFile, registryHostname); helper != "" {
294+
var store credentials.Store
295+
if helper := configFile.CredentialHelpers[registryHostname]; helper != "" {
297296
store = newNativeStore(configFile, helper)
297+
} else {
298+
store = credentials.NewFileStore(configFile)
298299
}
299300

300301
envConfig := os.Getenv(DockerEnvConfigKey)
@@ -361,18 +362,6 @@ func (configFile *ConfigFile) GetAuthConfig(registryHostname string) (types.Auth
361362
return configFile.GetCredentialsStore(registryHostname).Get(registryHostname)
362363
}
363364

364-
// getConfiguredCredentialStore returns the credential helper configured for the
365-
// given registry, the default credsStore, or the empty string if neither are
366-
// configured.
367-
func getConfiguredCredentialStore(c *ConfigFile, registryHostname string) string {
368-
if c.CredentialHelpers != nil && registryHostname != "" {
369-
if helper, exists := c.CredentialHelpers[registryHostname]; exists {
370-
return helper
371-
}
372-
}
373-
return c.CredentialsStore
374-
}
375-
376365
// GetAllCredentials returns all of the credentials stored in all of the
377366
// configured credential stores.
378367
func (configFile *ConfigFile) GetAllCredentials() (map[string]types.AuthConfig, error) {

0 commit comments

Comments
 (0)