Skip to content

Commit c501213

Browse files
committed
response to comments
Signed-off-by: Nick Santos <[email protected]>
1 parent 0fa754c commit c501213

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

session/auth/authprovider/authprovider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
)
3030

3131
const defaultExpiration = 60
32-
const dockerIndexConfigfileKey = "https://index.docker.io/v1/"
33-
const dockerRegistryHost = "registry-1.docker.io"
32+
const dockerHubConfigfileKey = "https://index.docker.io/v1/"
33+
const dockerHubRegistryHost = "registry-1.docker.io"
3434

3535
func NewDockerAuthProvider(cfg *configfile.ConfigFile) session.Attachable {
3636
return &authProvider{
@@ -186,8 +186,8 @@ func (ap *authProvider) getAuthConfig(host string) (*types.AuthConfig, error) {
186186
ap.mu.Lock()
187187
defer ap.mu.Unlock()
188188

189-
if host == dockerRegistryHost {
190-
host = dockerIndexConfigfileKey
189+
if host == dockerHubRegistryHost {
190+
host = dockerHubConfigfileKey
191191
}
192192

193193
if _, exists := ap.authConfigCache[host]; !exists {

session/auth/authprovider/authprovider_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ import (
1414
func TestFetchTokenCaching(t *testing.T) {
1515
cfg := &configfile.ConfigFile{
1616
AuthConfigs: map[string]types.AuthConfig{
17-
dockerIndexConfigfileKey: {Username: "user", RegistryToken: "hunter2"},
17+
dockerHubConfigfileKey: {Username: "user", RegistryToken: "hunter2"},
1818
},
1919
}
2020
p := NewDockerAuthProvider(cfg).(*authProvider)
21-
res, err := p.FetchToken(context.Background(), &auth.FetchTokenRequest{Host: dockerRegistryHost})
21+
res, err := p.FetchToken(context.Background(), &auth.FetchTokenRequest{Host: dockerHubRegistryHost})
2222
require.NoError(t, err)
2323
assert.Equal(t, "hunter2", res.Token)
2424

25-
cfg.AuthConfigs[dockerIndexConfigfileKey] = types.AuthConfig{Username: "user", RegistryToken: "hunter3"}
26-
res, err = p.FetchToken(context.Background(), &auth.FetchTokenRequest{Host: dockerRegistryHost})
25+
cfg.AuthConfigs[dockerHubConfigfileKey] = types.AuthConfig{Username: "user", RegistryToken: "hunter3"}
26+
res, err = p.FetchToken(context.Background(), &auth.FetchTokenRequest{Host: dockerHubRegistryHost})
2727
require.NoError(t, err)
2828

2929
// Verify that we cached the result instead of returning hunter3.

0 commit comments

Comments
 (0)