Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
cli/command: explicitly map AuthConfig fields instead of a direct cast#6516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -50,7 +50,16 @@ func ResolveAuthConfig(cfg *configfile.ConfigFile, index *registrytypes.IndexInf | ||
| } | ||
| a, _ := cfg.GetAuthConfig(configKey) | ||
| return registrytypes.AuthConfig(a) | ||
| return registrytypes.AuthConfig{ | ||
| Username: a.Username, | ||
| Password: a.Password, | ||
| ServerAddress: a.ServerAddress, | ||
| // TODO(thaJeztah): Are these expected to be included? | ||
| Auth: a.Auth, | ||
| IdentityToken: a.IdentityToken, | ||
| RegistryToken: a.RegistryToken, | ||
| } | ||
| } | ||
| // GetDefaultAuthConfig gets the default auth config given a serverAddress | ||
| @@ -69,9 +78,17 @@ func GetDefaultAuthConfig(cfg *configfile.ConfigFile, checkCredStore bool, serve | ||
| }, err | ||
| } | ||
| } | ||
| authCfg.ServerAddress = serverAddress | ||
| authCfg.IdentityToken = "" | ||
| return registrytypes.AuthConfig(authCfg), nil | ||
| return registrytypes.AuthConfig{ | ||
| Username: authCfg.Username, | ||
| Password: authCfg.Password, | ||
| ServerAddress: serverAddress, | ||
| // TODO(thaJeztah): Are these expected to be included? | ||
| Auth: authCfg.Auth, | ||
| IdentityToken: "", | ||
| RegistryToken: authCfg.RegistryToken, | ||
Comment on lines
+85
to
+90
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More so, because the | ||
| }, nil | ||
| } | ||
| // PromptUserForCredentials handles the CLI prompt for the user to input | ||
| @@ -186,7 +203,16 @@ func RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (strin | ||
| return "", err | ||
| } | ||
| encodedAuth, err := authconfig.Encode(registrytypes.AuthConfig(authConfig)) | ||
| encodedAuth, err := authconfig.Encode(registrytypes.AuthConfig{ | ||
| Username: authConfig.Username, | ||
| Password: authConfig.Password, | ||
| ServerAddress: authConfig.ServerAddress, | ||
| // TODO(thaJeztah): Are these expected to be included? | ||
| Auth: authConfig.Auth, | ||
| IdentityToken: authConfig.IdentityToken, | ||
| RegistryToken: authConfig.RegistryToken, | ||
| }) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we're resetting this field, but other places we either copy everything as-is, and in yet other places, we only include
Username,Password, andServerAddress- this needs some digging into. I suspect theAuthConfigstruct as defined in the API contains fields that were meant to be used by the registry client, and some fields not intended to be accepted through theX-Registry-Authheader.