Skip to content

Commit d421dea

Browse files
authored
Merge pull request docker#5908 from thaJeztah/client_api_version
remove uses of cli.DefaultVersion()
2 parents 1673cd8 + 79c9c7e commit d421dea

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

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: 11 additions & 10 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
}
@@ -196,8 +197,8 @@ func runVersion(ctx context.Context, dockerCli command.Cli, opts *versionOptions
196197
func prettyPrintVersion(dockerCli command.Cli, vd versionInfo, tmpl *template.Template) error {
197198
t := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 1, ' ', 0)
198199
err := tmpl.Execute(t, vd)
199-
t.Write([]byte("\n"))
200-
t.Flush()
200+
_, _ = t.Write([]byte("\n"))
201+
_ = t.Flush()
201202
return err
202203
}
203204

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)