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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-08-22 10:08:20 +02:00
parent ce22ac2736
commit 223d71a837
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 1 additions and 1 deletions

View File

@ -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)