-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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:
|
Arch: arch(), | ||
Context: contextName, | ||
Version: version.Version, | ||
APIVersion: api.DefaultVersion, |
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.
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
anddocker version --format='{{ json .Client }}' | jq .ApiVersion
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>
cli/command/system/runInfo: set negotiated API version when available
The current logic was ignoring (e.g.)
--format=json
formats, and wasonly 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.
differ, depending on the format:
If no server information is fetched:
If server information is fetched:
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)