Skip to content

Commit 7fc2305

Browse files
committed
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. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent e1c30df commit 7fc2305

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

cli/command/system/version.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
flagsHelper "github.com/docker/cli/cli/flags"
1717
"github.com/docker/cli/cli/version"
1818
"github.com/docker/cli/templates"
19+
"github.com/docker/docker/api"
1920
"github.com/docker/docker/api/types"
2021
"github.com/pkg/errors"
2122
"github.com/spf13/cobra"
@@ -89,13 +90,15 @@ type clientVersion struct {
8990
// information.
9091
func newClientVersion(contextName string, dockerCli command.Cli) clientVersion {
9192
v := clientVersion{
92-
Version: version.Version,
93-
GoVersion: runtime.Version(),
94-
GitCommit: version.GitCommit,
95-
BuildTime: reformatDate(version.BuildTime),
96-
Os: runtime.GOOS,
97-
Arch: arch(),
98-
Context: contextName,
93+
Version: version.Version,
94+
APIVersion: api.DefaultVersion,
95+
DefaultAPIVersion: api.DefaultVersion,
96+
GoVersion: runtime.Version(),
97+
GitCommit: version.GitCommit,
98+
BuildTime: reformatDate(version.BuildTime),
99+
Os: runtime.GOOS,
100+
Arch: arch(),
101+
Context: contextName,
99102
}
100103
if version.PlatformName != "" {
101104
v.Platform = &platformInfo{Name: version.PlatformName}

0 commit comments

Comments
 (0)