@@ -15,7 +15,6 @@ import (
1515 "github.com/docker/cli/cli/config/configfile"
1616 "github.com/docker/cli/cli/config/credentials"
1717 configtypes "github.com/docker/cli/cli/config/types"
18- "github.com/docker/docker/registry"
1918 "github.com/stretchr/testify/assert"
2019 "github.com/stretchr/testify/require"
2120 "go.podman.io/image/v5/docker/reference"
@@ -489,10 +488,10 @@ func TestGetCredentialsInteroperability(t *testing.T) {
489488
490489 // Log in. This is intended to match github.com/docker/cli/command/registry.runLogin
491490 serverAddress := c .loginKey
492- if serverAddress == "" {
493- serverAddress = registry .IndexServer
491+ if serverAddress == "" || serverAddress == "docker.io" { // github.com/docker/cli/internal/registry.DefaultNamespace
492+ serverAddress = "https://index.docker.io/v1/" // github.com/docker/cli/internal/ registry.IndexServer
494493 }
495- if serverAddress != registry . IndexServer {
494+ if serverAddress != "https://index.docker.io/v1/" { // github.com/docker/cli/internal/registry.IndexServer
496495 serverAddress = credentials .ConvertToHostname (serverAddress )
497496 }
498497 configFile , err := config .Load (configDir )
@@ -514,7 +513,7 @@ func TestGetCredentialsInteroperability(t *testing.T) {
514513 // Log out. This is intended to match github.com/docker/cli/command/registry.runLogout
515514 var regsToLogout []string
516515 if c .loginKey == "" {
517- regsToLogout = []string {registry .IndexServer }
516+ regsToLogout = []string {"https://index.docker.io/v1/" } // github.com/docker/cli/internal/ registry.IndexServer
518517 } else {
519518 hostnameAddress := credentials .ConvertToHostname (c .loginKey )
520519 regsToLogout = []string {c .loginKey , hostnameAddress , "http://" + hostnameAddress , "https://" + hostnameAddress }
@@ -915,11 +914,11 @@ func TestSetCredentialsInteroperability(t *testing.T) {
915914 dockerRef , err := dockerReference .ParseNormalizedNamed (c .queryRepo )
916915 require .NoError (t , err )
917916 dockerRef = dockerReference .TagNameOnly (dockerRef )
918- repoInfo , err := registry . ParseRepositoryInfo (dockerRef )
919- require . NoError ( t , err )
920- configKey := repoInfo . Index . Name
921- if repoInfo . Index . Official {
922- configKey = registry . IndexServer
917+ configKey := dockerReference . Domain (dockerRef )
918+ // github.com/docker/cli/command.RetrieveAuthTokenFromImage’s getAuthConfigKey internally hard-codes
919+ // these strings.
920+ if configKey == "docker.io" || configKey == "index.docker.io" {
921+ configKey = "https://index.docker.io/v1/" // github.com/docker/cli/command.authConfigKey
923922 }
924923
925924 if c .otherContents {
@@ -933,7 +932,7 @@ func TestSetCredentialsInteroperability(t *testing.T) {
933932 // Initially, there are no credentials
934933 configFile , err := config .Load (configDir )
935934 require .NoError (t , err )
936- creds , err := configFile .GetCredentialsStore ( configKey ). Get (configKey )
935+ creds , err := configFile .GetAuthConfig (configKey )
937936 require .NoError (t , err )
938937 assert .Equal (t , configtypes.AuthConfig {}, creds )
939938
@@ -947,7 +946,7 @@ func TestSetCredentialsInteroperability(t *testing.T) {
947946 // We can find the credentials.
948947 configFile , err = config .Load (configDir )
949948 require .NoError (t , err )
950- creds , err = configFile .GetCredentialsStore ( configKey ). Get (configKey )
949+ creds , err = configFile .GetAuthConfig (configKey )
951950 require .NoError (t , err )
952951 assert .Equal (t , configtypes.AuthConfig {
953952 ServerAddress : configKey ,
@@ -961,12 +960,12 @@ func TestSetCredentialsInteroperability(t *testing.T) {
961960 // We can’t find the credentials any more.
962961 configFile , err = config .Load (configDir )
963962 require .NoError (t , err )
964- creds , err = configFile .GetCredentialsStore ( configKey ). Get (configKey )
963+ creds , err = configFile .GetAuthConfig (configKey )
965964 require .NoError (t , err )
966965 assert .Equal (t , configtypes.AuthConfig {}, creds )
967966
968967 if c .otherContents {
969- creds , err = configFile .GetCredentialsStore ( "unmodified-domain.example" ). Get ("unmodified-domain.example" )
968+ creds , err = configFile .GetAuthConfig ("unmodified-domain.example" )
970969 require .NoError (t , err )
971970 assert .Equal (t , configtypes.AuthConfig {
972971 ServerAddress : "unmodified-domain.example" ,
0 commit comments