From 223d71a837a36a3c38e5d6e2c26b4073d9178b06 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 22 Aug 2023 10:08:20 +0200 Subject: [PATCH] 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. Signed-off-by: Sebastiaan van Stijn --- cli/command/system/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/system/info.go b/cli/command/system/info.go index d560c058ee..274b5b64cc 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -111,11 +111,11 @@ func runInfo(cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error fprintln(dockerCli.Err(), err) } } + info.ClientInfo.APIVersion = dockerCli.CurrentVersion() } if opts.format == "" { info.UserName = dockerCli.ConfigFile().AuthConfigs[registry.IndexServer].Username - info.ClientInfo.APIVersion = dockerCli.CurrentVersion() return prettyPrintInfo(dockerCli, info) } return formatInfo(dockerCli.Out(), info, opts.format)