diff --git a/cli/config/credentials/native_store.go b/cli/config/credentials/native_store.go index f9619b0381c8..b9af145b9dcb 100644 --- a/cli/config/credentials/native_store.go +++ b/cli/config/credentials/native_store.go @@ -51,6 +51,7 @@ func (c *nativeStore) Get(serverAddress string) (types.AuthConfig, error) { auth.Username = creds.Username auth.IdentityToken = creds.IdentityToken auth.Password = creds.Password + auth.ServerAddress = creds.ServerAddress return auth, nil } @@ -76,6 +77,9 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) { ac.Username = creds.Username ac.Password = creds.Password ac.IdentityToken = creds.IdentityToken + if ac.ServerAddress == "" { + ac.ServerAddress = creds.ServerAddress + } authConfigs[registry] = ac } diff --git a/cli/config/credentials/native_store_test.go b/cli/config/credentials/native_store_test.go index 2c6f230f681d..5abcca3587e0 100644 --- a/cli/config/credentials/native_store_test.go +++ b/cli/config/credentials/native_store_test.go @@ -145,9 +145,10 @@ func TestNativeStoreGet(t *testing.T) { assert.NilError(t, err) expected := types.AuthConfig{ - Username: "foo", - Password: "bar", - Email: "foo@example.com", + Username: "foo", + Password: "bar", + Email: "foo@example.com", + ServerAddress: validServerAddress, } assert.Check(t, is.DeepEqual(expected, actual)) } @@ -169,6 +170,7 @@ func TestNativeStoreGetIdentityToken(t *testing.T) { expected := types.AuthConfig{ IdentityToken: "abcd1234", Email: "foo@example2.com", + ServerAddress: validServerAddress2, } assert.Check(t, is.DeepEqual(expected, actual)) }