Skip to content
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

cli/command/registry: assorted refactor and test changes #5667

Merged
merged 6 commits into from
Dec 6, 2024

Conversation

thaJeztah
Copy link
Member

cli/command/registry: don't return creds on error

Be more explicit on not returning a response if there was an error;
change some non-exported functions to return a pointer, and return
nil instead.

cli/command/registry: loginWithRegistry: use shallower interface

This function only needs the API client, not all of the CLI.

cli/command/registry: storeCredentials: accept configfile as arg

This function only needs access to the configfile

cli/command/registry: TestLoginWithCredStoreCreds slight refactor

  • also check errors that were previously not handled
  • use the fakeCLI's buffer instead of creating one manually

cli/command/registry: return status only instead of whole response

Various functions were passing through the API response as a whole, but
effectively only needed it for a status message (if any). Reduce what's
returned to only the message.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Be more explicit on not returning a response if there was an error;
change some non-exported functions to return a pointer, and return
nil instead.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This function only needs the API client, not all of the CLI.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
This function only needs access to the configfile

Signed-off-by: Sebastiaan van Stijn <[email protected]>
- also check errors that were previously not handled
- use the fakeCLI's buffer instead of creating one manually

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Various functions were passing through the API response as a whole, but
effectively only needed it for a status message (if any). Reduce what's
returned to only the message.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added this to the 28.0.0 milestone Dec 4, 2024
@thaJeztah thaJeztah self-assigned this Dec 4, 2024
}
return nil
}

func loginWithStoredCredentials(ctx context.Context, dockerCli command.Cli, authConfig registrytypes.AuthConfig) (*registrytypes.AuthenticateOKBody, error) {
func loginWithStoredCredentials(ctx context.Context, dockerCli command.Cli, authConfig registrytypes.AuthConfig) (msg string, _ error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going back and forth a bit whether we'd ever would need more from the response returned here, but as we currently don't use anything from that (and these functions already handle the response and store it), as well as these being non-exported, I thought perhaps it's good to just return the thing we need and considering this a good hand-over point for API types to local information.

@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 27 lines in your changes missing coverage. Please review.

Project coverage is 59.49%. Comparing base (5afa739) to head (e398d16).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5667      +/-   ##
==========================================
- Coverage   59.53%   59.49%   -0.04%     
==========================================
  Files         346      346              
  Lines       29356    29358       +2     
==========================================
- Hits        17477    17468       -9     
- Misses      10909    10918       +9     
- Partials      970      972       +2     

@thaJeztah thaJeztah marked this pull request as ready for review December 4, 2024 10:22
Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit 97010d1 into docker:master Dec 6, 2024
104 checks passed
@thaJeztah thaJeztah deleted the login_clean branch December 6, 2024 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants