Skip to content

Commit 4286883

Browse files
committed
cli/command: inline resolveAuthConfigFromImage
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 2d3b0b3 commit 4286883

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

cli/command/registry.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
205205
func 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

Comments
 (0)