Skip to content

Commit 5f13d0f

Browse files
committed
remove uses of cli.DefaultVersion()
It's hard-coded to the API defaultversion, so we can use that const directly. Ultimately, this should be something returned by the API client configured on the CLI, not the CLI itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 2eec746 commit 5f13d0f

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

cli/command/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type DockerCli struct {
8888
enableGlobalMeter, enableGlobalTracer bool
8989
}
9090

91-
// DefaultVersion returns api.defaultVersion.
91+
// DefaultVersion returns [api.DefaultVersion].
9292
func (*DockerCli) DefaultVersion() string {
9393
return api.DefaultVersion
9494
}

cli/command/system/version.go

Lines changed: 9 additions & 8 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,20 +90,20 @@ 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+
DefaultAPIVersion: api.DefaultVersion,
95+
GoVersion: runtime.Version(),
96+
GitCommit: version.GitCommit,
97+
BuildTime: reformatDate(version.BuildTime),
98+
Os: runtime.GOOS,
99+
Arch: arch(),
100+
Context: contextName,
99101
}
100102
if version.PlatformName != "" {
101103
v.Platform = &platformInfo{Name: version.PlatformName}
102104
}
103105
if dockerCli != nil {
104106
v.APIVersion = dockerCli.CurrentVersion()
105-
v.DefaultAPIVersion = dockerCli.DefaultVersion()
106107
}
107108
return v
108109
}

internal/test/cli.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
registryclient "github.com/docker/cli/cli/registry/client"
1515
"github.com/docker/cli/cli/streams"
1616
"github.com/docker/cli/cli/trust"
17+
"github.com/docker/docker/api"
1718
"github.com/docker/docker/client"
1819
notaryclient "github.com/theupdateframework/notary/client"
1920
)
@@ -104,8 +105,8 @@ func (c *FakeCli) Client() client.APIClient {
104105
}
105106

106107
// CurrentVersion returns the API version used by FakeCli.
107-
func (c *FakeCli) CurrentVersion() string {
108-
return c.DefaultVersion()
108+
func (*FakeCli) CurrentVersion() string {
109+
return api.DefaultVersion
109110
}
110111

111112
// Out returns the output stream (stdout) the cli should write on

0 commit comments

Comments
 (0)