cli/command/system: printServerWarnings: use client API version from info

Set the client's API version that's used in the info, instead of requesting
it as part of printing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-04-14 00:49:49 +02:00
parent be307c5792
commit da3871fd8e
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 6 additions and 5 deletions

View File

@ -115,6 +115,7 @@ func runInfo(cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error
if opts.format == "" {
info.UserName = dockerCli.ConfigFile().AuthConfigs[registry.IndexServer].Username
info.ClientInfo.APIVersion = dockerCli.CurrentVersion()
return prettyPrintInfo(dockerCli, info)
}
return formatInfo(dockerCli, info, opts.format)
@ -366,7 +367,7 @@ func prettyPrintServerInfo(dockerCli command.Cli, info *info) []error {
fmt.Fprint(dockerCli.Out(), "\n")
printServerWarnings(dockerCli, *info.Info)
printServerWarnings(dockerCli, info)
return errs
}
@ -440,16 +441,16 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) {
}
}
func printServerWarnings(dockerCli command.Cli, info types.Info) {
if versions.LessThan(dockerCli.Client().ClientVersion(), "1.42") {
printSecurityOptionsWarnings(dockerCli, info)
func printServerWarnings(dockerCli command.Cli, info *info) {
if versions.LessThan(info.ClientInfo.APIVersion, "1.42") {
printSecurityOptionsWarnings(dockerCli, *info.Info)
}
if len(info.Warnings) > 0 {
fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n"))
return
}
// daemon didn't return warnings. Fallback to old behavior
printServerWarningsLegacy(dockerCli, info)
printServerWarningsLegacy(dockerCli, *info.Info)
}
// printSecurityOptionsWarnings prints warnings based on the security options