8000 cli/command/system/runInfo: set client API defaults, and negotiated API version when available by thaJeztah · Pull Request #4507 · docker/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cli/command/system/runInfo: set client API defaults, and negotiated API version when available #4507

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thaJeztah
Copy link
Member

cli/command/system/runInfo: set negotiated API version when available

The current logic was ignoring (e.g.) --format=json formats, and was
only setting the negotiated API version if no format was specified.

While we do want to avoid calling the API if possible, we do already
check if the given template requires a server connection, so let's
move updating the API version to that block.

cli/command/system/newClientVersion: initialize with default API version

Set the APIVersion and DefaultAPIVersion fields to the default version,
as that's the version the client assumes without making a API connection
to do version negotiation.

⚠️ One change worth mentioning is that this means that the API version will
differ, depending on the format:

If no server information is fetched:

docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
"1.44"

If server information is fetched:

docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
"1.43"

An alternative could be to leave the ApiVersion field empty if no
negotiation took place.

- Description for the changelog

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

@codecov-commenter
Copy link
codecov-commenter commented Nov 23, 2023

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 59.05%. Comparing base (fc99fe2) to head (c0482fd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4507      +/-   ##
==========================================
- Coverage   59.05%   59.05%   -0.01%     
==========================================
  Files         357      357              
  Lines       29843    29846       +3     
==========================================
+ Hits        17624    17625       +1     
- Misses      11241    11243       +2     
  Partials      978      978              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Arch: arch(),
Context: contextName,
Version: version.Version,
APIVersion: api.DefaultVersion,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If no server information is fetched:

docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
"1.44"

If server information is fetched:

docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
"1.43"

An alternative could be to leave the ApiVersion field empty if no negotiation took place.

Hmm not sure about this one.

On one side it's weird for the version to be different depending on the format, on the other side side being empty is also not great.

I think leaving it empty if no negotiation took place would be slightly more useful:

  • It's already that way so there's no existing expectation that it's always non-empty
  • Empty value is better than misleading value as it's easier to notice
  • The CLI APIVersion that's not impacted by the server negotiation is already there in DefaultAPIVersion and docker version --format='{{ json .Client }}' | jq .ApiVersion

@thaJeztah thaJeztah modified the milestones: 25.0.0, 26.0.0 Jan 19, 2024
@vvoland vvoland modified the milestones: 26.0.0, 27.0.0 Mar 14, 2024
@vvoland vvoland modified the milestones: 27.0.0, 28.0.0 Jun 20, 2024
@thaJeztah thaJeztah modified the milestones: 28.0.0, 28.0.5 Mar 31, 2025
The current logic was ignoring (e.g.) `--format=json` formats, and was
only setting the negotiated API version if no format was specified.

While we do want to avoid calling the API if possible, we do already
check if the given template requires a server connection, so let's
move updating the API version to that block.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Set the APIVersion and DefaultAPIVersion fields to the default version,
as that's the version the client assumes without making a API connection
to do version negotiation.

One change worth mentioning is that this means that the API version will
differ, depending on the format:

If no server information is fetched:

    docker info --format='{{ json .ClientInfo }}' | jq .ApiVersion
    "1.44"

If server information is fetched:

    docker info --format='{{ json .}}' | jq .ClientInfo.ApiVersion
    "1.43"

An alternative could be to leave the ApiVersion field empty if no
negotiation took place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0