@@ -63,17 +63,14 @@ func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInf
63
63
indexServer := registry .GetAuthConfigKey (index )
64
64
isDefaultRegistry := indexServer == ElectAuthServer (context .Background (), cli )
65
65
authConfig , err := GetDefaultAuthConfig (cli , true , indexServer , isDefaultRegistry )
66
- if authConfig == nil {
67
- authConfig = & types.AuthConfig {}
68
- }
69
66
if err != nil {
70
67
fmt .Fprintf (cli .Err (), "Unable to retrieve stored credentials for %s, error: %s.\n " , indexServer , err )
71
68
}
72
- err = ConfigureAuth (cli , "" , "" , authConfig , isDefaultRegistry )
69
+ err = ConfigureAuth (cli , "" , "" , & authConfig , isDefaultRegistry )
73
70
if err != nil {
74
71
return "" , err
75
72
}
76
- return EncodeAuthToBase64 (* authConfig )
73
+ return EncodeAuthToBase64 (authConfig )
77
74
}
78
75
}
79
76
@@ -92,7 +89,7 @@ func ResolveAuthConfig(ctx context.Context, cli Cli, index *registrytypes.IndexI
92
89
93
90
// GetDefaultAuthConfig gets the default auth config given a serverAddress
94
91
// If credentials for given serverAddress exists in the credential store, the configuration will be populated with values in it
95
- func GetDefaultAuthConfig (cli Cli , checkCredStore bool , serverAddress string , isDefaultRegistry bool ) (* types.AuthConfig , error ) {
92
+ func GetDefaultAuthConfig (cli Cli , checkCredStore bool , serverAddress string , isDefaultRegistry bool ) (types.AuthConfig , error ) {
96
93
if ! isDefaultRegistry {
97
94
serverAddress = registry .ConvertToHostname (serverAddress )
98
95
}
@@ -101,13 +98,15 @@ func GetDefaultAuthConfig(cli Cli, checkCredStore bool, serverAddress string, is
101
98
if checkCredStore {
102
99
authconfig , err = cli .ConfigFile ().GetAuthConfig (serverAddress )
103
100
if err != nil {
104
- return nil , err
101
+ return types.AuthConfig {
102
+ ServerAddress : serverAddress ,
103
+ }, err
105
104
}
106
105
}
107
106
authconfig .ServerAddress = serverAddress
108
107
authconfig .IdentityToken = ""
109
108
res := types .AuthConfig (authconfig )
110
- return & res , nil
109
+ return res , nil
111
110
}
112
111
113
112
// ConfigureAuth handles prompting of user's username and password if needed
0 commit comments