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

Function GetDefaultAuthConfig

cli/command/registry.go:64–89  ·  view source on GitHub ↗

GetDefaultAuthConfig gets the default auth config given a serverAddress If credentials for given serverAddress exists in the credential store, the configuration will be populated with values in it

(cfg *configfile.ConfigFile, checkCredStore bool, serverAddress string, isDefaultRegistry bool)

Source from the content-addressed store, hash-verified

62// GetDefaultAuthConfig gets the default auth config given a serverAddress
63// If credentials for given serverAddress exists in the credential store, the configuration will be populated with values in it
64func GetDefaultAuthConfig(cfg *configfile.ConfigFile, checkCredStore bool, serverAddress string, isDefaultRegistry bool) (registrytypes.AuthConfig, error) {
65 if !isDefaultRegistry {
66 serverAddress = credentials.ConvertToHostname(serverAddress)
67 }
68 authCfg := configtypes.AuthConfig{}
69 var err error
70 if checkCredStore {
71 authCfg, err = cfg.GetAuthConfig(serverAddress)
72 if err != nil {
73 return registrytypes.AuthConfig{
74 ServerAddress: serverAddress,
75 }, err
76 }
77 }
78
79 return registrytypes.AuthConfig{
80 Username: authCfg.Username,
81 Password: authCfg.Password,
82 ServerAddress: serverAddress,
83
84 // TODO(thaJeztah): Are these expected to be included?
85 Auth: authCfg.Auth,
86 IdentityToken: "",
87 RegistryToken: authCfg.RegistryToken,
88 }, nil
89}
90
91// PromptUserForCredentials handles the CLI prompt for the user to input
92// credentials.

Callers

nothing calls this directly

Calls 1

GetAuthConfigMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…