From e3c1a7c70de0bc96c20ef23d3113f37a42eb75d6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 20 Aug 2025 12:34:35 +0200 Subject: [PATCH] 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 --- cli/config/configfile/file.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/cli/config/configfile/file.go b/cli/config/configfile/file.go index 26e148f05987..a619690a6fc2 100644 --- a/cli/config/configfile/file.go +++ b/cli/config/configfile/file.go @@ -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) @@ -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) {