Skip to content

Commit 2b521e4

Browse files
authored
Merge pull request #4655 from StealthyCoder/4653-fix-credential-helper
Fix setting ServerAddress property in NativeStore
2 parents 1862725 + b24e7f8 commit 2b521e4

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

cli/config/credentials/native_store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (c *nativeStore) Get(serverAddress string) (types.AuthConfig, error) {
5151
auth.Username = creds.Username
5252
auth.IdentityToken = creds.IdentityToken
5353
auth.Password = creds.Password
54+
auth.ServerAddress = creds.ServerAddress
5455

5556
return auth, nil
5657
}
@@ -76,6 +77,9 @@ func (c *nativeStore) GetAll() (map[string]types.AuthConfig, error) {
7677
ac.Username = creds.Username
7778
ac.Password = creds.Password
7879
ac.IdentityToken = creds.IdentityToken
80+
if ac.ServerAddress == "" {
81+
ac.ServerAddress = creds.ServerAddress
82+
}
7983
authConfigs[registry] = ac
8084
}
8185

cli/config/credentials/native_store_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ func TestNativeStoreGet(t *testing.T) {
145145
assert.NilError(t, err)
146146

147147
expected := types.AuthConfig{
148-
Username: "foo",
149-
Password: "bar",
150-
Email: "foo@example.com",
148+
Username: "foo",
149+
Password: "bar",
150+
Email: "foo@example.com",
151+
ServerAddress: validServerAddress,
151152
}
152153
assert.Check(t, is.DeepEqual(expected, actual))
153154
}
@@ -169,6 +170,7 @@ func TestNativeStoreGetIdentityToken(t *testing.T) {
169170
expected := types.AuthConfig{
170171
IdentityToken: "abcd1234",
171172
Email: "foo@example2.com",
173+
ServerAddress: validServerAddress2,
172174
}
173175
assert.Check(t, is.DeepEqual(expected, actual))
174176
}

0 commit comments

Comments
 (0)