|
@@ -58,17 +58,29 @@ func (c *nativeStore) Get(serverAddress string) (types.AuthConfig, error) {
|
|
|
|
|
|
// GetAll retrieves all the credentials from the native store.
|
|
// GetAll retrieves all the credentials from the native store.
|
|
func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
|
|
func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
|
|
- auths, _ := c.fileStore.GetAll()
|
|
|
|
|
|
+ auths, err := c.listCredentialsInStore()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Emails are only stored in the file store.
|
|
|
|
+ // This call can be safely eliminated when emails are removed.
|
|
|
|
+ fileConfigs, _ := c.fileStore.GetAll()
|
|
|
|
|
|
- for s, ac := range auths {
|
|
|
|
- creds, _ := c.getCredentialsFromStore(s)
|
|
|
|
|
|
+ authConfigs := make(map[string]types.AuthConfig)
|
|
|
|
+ for registry := range auths {
|
|
|
|
+ creds, err := c.getCredentialsFromStore(registry)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ ac, _ := fileConfigs[registry] // might contain Email
|
|
ac.Username = creds.Username
|
|
ac.Username = creds.Username
|
|
ac.Password = creds.Password
|
|
ac.Password = creds.Password
|
|
ac.IdentityToken = creds.IdentityToken
|
|
ac.IdentityToken = creds.IdentityToken
|
|
- auths[s] = ac
|
|
|
|
|
|
+ authConfigs[registry] = ac
|
|
}
|
|
}
|
|
|
|
|
|
- return auths, nil
|
|
|
|
|
|
+ return authConfigs, nil
|
|
}
|
|
}
|
|
|
|
|
|
// Store saves the given credentials in the file store.
|
|
// Store saves the given credentials in the file store.
|
|
@@ -124,3 +136,9 @@ func (c *nativeStore) getCredentialsFromStore(serverAddress string) (types.AuthC
|
|
ret.ServerAddress = serverAddress
|
|
ret.ServerAddress = serverAddress
|
|
return ret, nil
|
|
return ret, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// listCredentialsInStore returns a listing of stored credentials as a map of
|
|
|
|
+// URL -> username.
|
|
|
|
+func (c *nativeStore) listCredentialsInStore() (map[string]string, error) {
|
|
|
|
+ return client.List(c.programFunc)
|
|
|
|
+}
|