Skip to content

Commit 96a2674

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 1df8feb commit 96a2674

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
@@ -290,10 +290,11 @@ func decodeAuth(authStr string) (string, string, error) {
290290
// GetCredentialsStore returns a new credentials store from the settings in the
291291
// configuration file
292292
func (configFile *ConfigFile) GetCredentialsStore(registryHostname string) credentials.Store {
293-
store := credentials.NewFileStore(configFile)
294-
295-
if helper := getConfiguredCredentialStore(configFile, registryHostname); helper != "" {
293+
var store credentials.Store
294+
if helper := configFile.CredentialHelpers[registryHostname]; helper != "" {
296295
store = newNativeStore(configFile, helper)
296+
} else {
297+
store = credentials.NewFileStore(configFile)
297298
}
298299

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

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

0 commit comments

Comments
 (0)