Skip to content

Commit da3871f

Browse files
committed
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>
1 parent be307c5 commit da3871f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cli/command/system/info.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func runInfo(cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error
115115

116116
if opts.format == "" {
117117
info.UserName = dockerCli.ConfigFile().AuthConfigs[registry.IndexServer].Username
118+
info.ClientInfo.APIVersion = dockerCli.CurrentVersion()
118119
return prettyPrintInfo(dockerCli, info)
119120
}
120121
return formatInfo(dockerCli, info, opts.format)
@@ -366,7 +367,7 @@ func prettyPrintServerInfo(dockerCli command.Cli, info *info) []error {
366367

367368
fmt.Fprint(dockerCli.Out(), "\n")
368369

369-
printServerWarnings(dockerCli, *info.Info)
370+
printServerWarnings(dockerCli, info)
370371
return errs
371372
}
372373

@@ -440,16 +441,16 @@ func printSwarmInfo(dockerCli command.Cli, info types.Info) {
440441
}
441442
}
442443

443-
func printServerWarnings(dockerCli command.Cli, info types.Info) {
444-
if versions.LessThan(dockerCli.Client().ClientVersion(), "1.42") {
445-
printSecurityOptionsWarnings(dockerCli, info)
444+
func printServerWarnings(dockerCli command.Cli, info *info) {
445+
if versions.LessThan(info.ClientInfo.APIVersion, "1.42") {
446+
printSecurityOptionsWarnings(dockerCli, *info.Info)
446447
}
447448
if len(info.Warnings) > 0 {
448449
fmt.Fprintln(dockerCli.Err(), strings.Join(info.Warnings, "\n"))
449450
return
450451
}
451452
// daemon didn't return warnings. Fallback to old behavior
452-
printServerWarningsLegacy(dockerCli, info)
453+
printServerWarningsLegacy(dockerCli, *info.Info)
453454
}
454455

455456
// printSecurityOptionsWarnings prints warnings based on the security options

0 commit comments

Comments
 (0)