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)
| 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 |
| 64 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…