getCredentialsFromStore executes the command to get the credentials from the native store.
(serverAddress string)
| 117 | |
| 118 | // getCredentialsFromStore executes the command to get the credentials from the native store. |
| 119 | func (c *nativeStore) getCredentialsFromStore(serverAddress string) (types.AuthConfig, error) { |
| 120 | var ret types.AuthConfig |
| 121 | |
| 122 | creds, err := client.Get(c.programFunc, serverAddress) |
| 123 | if err != nil { |
| 124 | if credentials.IsErrCredentialsNotFound(err) { |
| 125 | // do not return an error if the credentials are not |
| 126 | // in the keychain. Let docker ask for new credentials. |
| 127 | return ret, nil |
| 128 | } |
| 129 | return ret, err |
| 130 | } |
| 131 | |
| 132 | if creds.Username == tokenUsername { |
| 133 | ret.IdentityToken = creds.Secret |
| 134 | } else { |
| 135 | ret.Password = creds.Secret |
| 136 | ret.Username = creds.Username |
| 137 | } |
| 138 | |
| 139 | ret.ServerAddress = serverAddress |
| 140 | return ret, nil |
| 141 | } |
| 142 | |
| 143 | // listCredentialsInStore returns a listing of stored credentials as a map of |
| 144 | // URL -> username. |