@@ -203,30 +203,21 @@ func PromptUserForCredentials(ctx context.Context, cli Cli, argUser, argPassword
203203//
204204// [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
205205func RetrieveAuthTokenFromImage (cfg * configfile.ConfigFile , image string ) (string , error ) {
206- // Retrieve encoded auth token from the image reference
207- authConfig , err := resolveAuthConfigFromImage (cfg , image )
206+ registryRef , err := reference .ParseNormalizedNamed (image )
208207 if err != nil {
209208 return "" , err
210209 }
211- encodedAuth , err := registrytypes .EncodeAuthConfig (authConfig )
210+ configKey := getAuthConfigKey (reference .Domain (registryRef ))
211+ authConfig , err := cfg .GetAuthConfig (configKey )
212212 if err != nil {
213213 return "" , err
214214 }
215- return encodedAuth , nil
216- }
217215
218- // resolveAuthConfigFromImage retrieves that AuthConfig using the image string
219- func resolveAuthConfigFromImage (cfg * configfile.ConfigFile , image string ) (registrytypes.AuthConfig , error ) {
220- registryRef , err := reference .ParseNormalizedNamed (image )
216+ encodedAuth , err := registrytypes .EncodeAuthConfig (registrytypes .AuthConfig (authConfig ))
221217 if err != nil {
222- return registrytypes.AuthConfig {}, err
223- }
224- configKey := getAuthConfigKey (reference .Domain (registryRef ))
225- a , err := cfg .GetAuthConfig (configKey )
226- if err != nil {
227- return registrytypes.AuthConfig {}, err
218+ return "" , err
228219 }
229- return registrytypes . AuthConfig ( a ) , nil
220+ return encodedAuth , nil
230221}
231222
232223// getAuthConfigKey special-cases using the full index address of the official
0 commit comments