Skip to content

Commit 9dc6285

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 <[email protected]>
1 parent 75f3c08 commit 9dc6285

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

cli/config/configfile/file.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,11 @@ func decodeAuth(authStr string) (string, string, error) {
287287
// GetCredentialsStore returns a new credentials store from the settings in the
288288
// configuration file
289289
func (configFile *ConfigFile) GetCredentialsStore(registryHostname string) credentials.Store {
290-
store := credentials.NewFileStore(configFile)
291-
292-
if helper := getConfiguredCredentialStore(configFile, registryHostname); helper != "" {
290+
var store credentials.Store
291+
if helper := configFile.CredentialHelpers[registryHostname]; helper != "" {
293292
store = newNativeStore(configFile, helper)
293+
} else {
294+
store = credentials.NewFileStore(configFile)
294295
}
295296

296297
envConfig := os.Getenv(DockerEnvConfigKey)
@@ -357,18 +358,6 @@ func (configFile *ConfigFile) GetAuthConfig(registryHostname string) (types.Auth
357358
return configFile.GetCredentialsStore(registryHostname).Get(registryHostname)
358359
}
359360

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

0 commit comments

Comments
 (0)