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/system: prettyPrintServerInfo: don't depend on IndexServerAddress and credential-store #4205

Merged

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Apr 13, 2023

cli/command/system: prettyPrintServerInfo: simplify username

Starting with b4ca1c7 (#2819), docker login no longer depends on info.IndexServerAddress to determine the default registry.

The prettyPrintServerInfo() still depended on this information, which could potentially show the wrong information.

This patch changes it to also depend on the same information as docker login now does.

cli/command/system: prettyPrintServerInfo: move out collecting username

Make this function only print the info we have, and not read the username
from the credential-store.

This patch adds a Username field to the (local) info type, and sets it
when needed, so that prettyPrintServerInfo only has to format and print
the information, instead of calling out to the credential-store.

cli/command/system: printServerWarnings: use client API version from info

Set the client's API version that's used in the info, instead of requesting
it as part of printing.

- Description for the changelog

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

Starting with b4ca1c7, docker login
no longer depends on info.IndexServerAddress to determine the default
registry.

The prettyPrintServerInfo() still depended on this information, which
could potentially show the wrong information.

This patch changes it to also depend on the same information as docker login
now does.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Make this function only _print_ the info we have, and not read the username
from the credential-store.

This patch adds a Username field to the (local) `info` type, and sets it
when needed, so that prettyPrintServerInfo only has to format and print
the information, instead of calling out to the credential-store.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…info

Set the client's API version that's used in the info, instead of requesting
it as part of printing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter
Copy link

codecov-commenter commented Apr 13, 2023

Codecov Report

Merging #4205 (da3871f) into master (60d0659) will decrease coverage by 0.01%.
The diff coverage is 80.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4205      +/-   ##
==========================================
- Coverage   58.86%   58.85%   -0.01%     
==========================================
  Files         572      572              
  Lines       49544    49538       -6     
==========================================
- Hits        29162    29158       -4     
  Misses      18616    18616              
+ Partials     1766     1764       -2     

}
}

fprintlnNonEmpty(dockerCli.Out(), " Username:", info.UserName)
Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW, I'm also very much leaning towards moving this information to the Client: section, because nothing about it is part of the "Server:".

I think this was historically because it depended on the server (?) but no real idea.

Also;

  • because it's not part of the actual info.Info struct (i.e., the Server part), it's currently not even possible to use docker info --format <template> to show the name
  • ^^ so docker info --format=json won't show it
  • ^^ AND if a credentials-helper is used, it's not even filled in at all (it only looks in the config file
  • 🙃 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

So ... perhaps we should either remove it altogether, or make it use the actual credential-store in use, BUT reading info from that is not always .. fast, and I don't want docker info to become slow 😓

@thaJeztah thaJeztah merged commit 04bf047 into docker:master Apr 26, 2023
@thaJeztah thaJeztah deleted the info_dont_depend_on_IndexServerAddress branch April 26, 2023 11:07
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.

4 participants