MCPcopy Create free account
hub / github.com/docker/cli / GetCredentialsStore

Method GetCredentialsStore

cli/config/configfile/file.go:321–351  ·  view source on GitHub ↗

GetCredentialsStore returns a new credentials store from the settings in the configuration file

(registryHostname string)

Source from the content-addressed store, hash-verified

319// GetCredentialsStore returns a new credentials store from the settings in the
320// configuration file
321func (c *ConfigFile) GetCredentialsStore(registryHostname string) credentials.Store {
322 store := credentials.NewFileStore(c)
323
324 if helper := getConfiguredCredentialStore(c, getAuthConfigKey(registryHostname)); helper != "" {
325 store = newNativeStore(c, helper)
326 }
327
328 envConfig := os.Getenv(DockerEnvConfigKey)
329 if envConfig == "" {
330 return store
331 }
332
333 authConfig, err := parseEnvConfig(envConfig)
334 if err != nil {
335 _, _ = fmt.Fprintln(os.Stderr, "Failed to create credential store from DOCKER_AUTH_CONFIG: ", err)
336 return store
337 }
338
339 // use DOCKER_AUTH_CONFIG if set
340 // it uses the native or file store as a fallback to fetch and store credentials
341 envStore, err := memorystore.New(
342 memorystore.WithAuthConfig(authConfig),
343 memorystore.WithFallbackStore(store),
344 )
345 if err != nil {
346 _, _ = fmt.Fprintln(os.Stderr, "Failed to create credential store from DOCKER_AUTH_CONFIG: ", err)
347 return store
348 }
349
350 return envStore
351}
352
353func parseEnvConfig(v string) (map[string]types.AuthConfig, error) {
354 envConfig := &configEnv{}

Callers 8

GetAuthConfigMethod · 0.95
GetAllCredentialsMethod · 0.95
TestGetDefaultAuthConfigFunction · 0.80
TestRunLoginFunction · 0.80
TestLoginNonInteractiveFunction · 0.80
loginWithDeviceCodeFlowFunction · 0.80
storeCredentialsFunction · 0.80
runLogoutFunction · 0.80

Calls 3

parseEnvConfigFunction · 0.85
getAuthConfigKeyFunction · 0.70

Tested by 3

TestGetDefaultAuthConfigFunction · 0.64
TestRunLoginFunction · 0.64
TestLoginNonInteractiveFunction · 0.64