Merge pull request #5908 from thaJeztah/client_api_version

remove uses of cli.DefaultVersion()
This commit is contained in:
Sebastiaan van Stijn 2025-03-11 10:07:31 +01:00 committed by GitHub
commit d421dea843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 13 deletions

View File

@ -88,7 +88,7 @@ type DockerCli struct {
enableGlobalMeter, enableGlobalTracer bool enableGlobalMeter, enableGlobalTracer bool
} }
// DefaultVersion returns api.defaultVersion. // DefaultVersion returns [api.DefaultVersion].
func (*DockerCli) DefaultVersion() string { func (*DockerCli) DefaultVersion() string {
return api.DefaultVersion return api.DefaultVersion
} }

View File

@ -16,6 +16,7 @@ import (
flagsHelper "github.com/docker/cli/cli/flags" flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/cli/version" "github.com/docker/cli/cli/version"
"github.com/docker/cli/templates" "github.com/docker/cli/templates"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -89,20 +90,20 @@ type clientVersion struct {
// information. // information.
func newClientVersion(contextName string, dockerCli command.Cli) clientVersion { func newClientVersion(contextName string, dockerCli command.Cli) clientVersion {
v := clientVersion{ v := clientVersion{
Version: version.Version, Version: version.Version,
GoVersion: runtime.Version(), DefaultAPIVersion: api.DefaultVersion,
GitCommit: version.GitCommit, GoVersion: runtime.Version(),
BuildTime: reformatDate(version.BuildTime), GitCommit: version.GitCommit,
Os: runtime.GOOS, BuildTime: reformatDate(version.BuildTime),
Arch: arch(), Os: runtime.GOOS,
Context: contextName, Arch: arch(),
Context: contextName,
} }
if version.PlatformName != "" { if version.PlatformName != "" {
v.Platform = &platformInfo{Name: version.PlatformName} v.Platform = &platformInfo{Name: version.PlatformName}
} }
if dockerCli != nil { if dockerCli != nil {
v.APIVersion = dockerCli.CurrentVersion() v.APIVersion = dockerCli.CurrentVersion()
v.DefaultAPIVersion = dockerCli.DefaultVersion()
} }
return v return v
} }
@ -196,8 +197,8 @@ func runVersion(ctx context.Context, dockerCli command.Cli, opts *versionOptions
func prettyPrintVersion(dockerCli command.Cli, vd versionInfo, tmpl *template.Template) error { func prettyPrintVersion(dockerCli command.Cli, vd versionInfo, tmpl *template.Template) error {
t := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 1, ' ', 0) t := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 1, ' ', 0)
err := tmpl.Execute(t, vd) err := tmpl.Execute(t, vd)
t.Write([]byte("\n")) _, _ = t.Write([]byte("\n"))
t.Flush() _ = t.Flush()
return err return err
} }

View File

@ -14,6 +14,7 @@ import (
registryclient "github.com/docker/cli/cli/registry/client" registryclient "github.com/docker/cli/cli/registry/client"
"github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/streams"
"github.com/docker/cli/cli/trust" "github.com/docker/cli/cli/trust"
"github.com/docker/docker/api"
"github.com/docker/docker/client" "github.com/docker/docker/client"
notaryclient "github.com/theupdateframework/notary/client" notaryclient "github.com/theupdateframework/notary/client"
) )
@ -104,8 +105,8 @@ func (c *FakeCli) Client() client.APIClient {
} }
// CurrentVersion returns the API version used by FakeCli. // CurrentVersion returns the API version used by FakeCli.
func (c *FakeCli) CurrentVersion() string { func (*FakeCli) CurrentVersion() string {
return c.DefaultVersion() return api.DefaultVersion
} }
// Out returns the output stream (stdout) the cli should write on // Out returns the output stream (stdout) the cli should write on