cli/command/system/runInfo: set client API defaults, and negotiated API version when available
- relates to https://github.com/docker/cli/pull/4506
- relates to https://github.com/docker/cli/pull/4505
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.
:warning: 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 Report
Merging #4507 (c2f3e17) into master (ce22ac2) will increase coverage by
0.00%. The diff coverage is90.00%.
Additional details and impacted files
@@ Coverage Diff @@
## master #4507 +/- ##
=======================================
Coverage 59.75% 59.75%
=======================================
Files 287 287
Lines 24821 24823 +2
=======================================
+ Hits 14832 14834 +2
Misses 9103 9103
Partials 886 886