diff --git a/internal/registry/desktop.go b/internal/registry/desktop.go index 718d08da8..043e67528 100644 --- a/internal/registry/desktop.go +++ b/internal/registry/desktop.go @@ -104,7 +104,7 @@ func (p *desktopAuthProvider) GetAuthConfig(registryHostname string) (clitypes.A if session := p.sessionFor(registryHostname); session != nil { if auth, ok := session.auth(); ok { if registryHost(registryHostname) == DHIRegistryHost { - auth.ServerAddress = DHIRegistryHost + auth.ServerAddress = DHIIndexServer } return auth, nil } diff --git a/internal/registry/desktop_test.go b/internal/registry/desktop_test.go index 5a4b39d8d..40c0c083f 100644 --- a/internal/registry/desktop_test.go +++ b/internal/registry/desktop_test.go @@ -214,14 +214,14 @@ func TestDesktopAuthProvider_OtherRegistriesUseFallback(t *testing.T) { } func TestDesktopAuthProvider_DHIUsesDockerHubSession(t *testing.T) { - for _, host := range []string{DHIRegistryHost, "https://" + DHIRegistryHost, "https://" + DHIRegistryHost + "/"} { + for _, host := range []string{DHIRegistryHost, DHIIndexServer, DHIIndexServer + "/"} { t.Run(host, func(t *testing.T) { hub := &fakeHub{session: hubSession("hubuser", testNow.Add(time.Hour))} p := newTestProvider(hub, nil) p.signInToStaging() want := desktopCredentials() - want.ServerAddress = DHIRegistryHost + want.ServerAddress = DHIIndexServer got, err := p.GetAuthConfig(host) assert.NilError(t, err) assert.DeepEqual(t, got, want) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 079e857c2..cccd7a565 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -45,6 +45,8 @@ const ( StagingIndexServer = "https://" + StagingRegistryHost + "/" // DHIRegistryHost is the Docker Hardened Images registry. DHIRegistryHost = "dhi.io" + // DHIIndexServer is the credentials key for DHIRegistryHost. + DHIIndexServer = "https://" + DHIRegistryHost ) // GetAuthConfigKey special-cases using the full index address of the official