cli/command/system: prettyInfo: accept Streams

No need to pass whole of DockerCLI, as all it needs is the outputs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-05-02 16:54:05 +02:00
parent 8cfefc6ea2
commit 1e89037d72
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 9 additions and 9 deletions

View File

@ -160,29 +160,29 @@ func needsServerInfo(template string, info info) bool {
return err != nil
}
func prettyPrintInfo(dockerCli command.Cli, info info) error {
func prettyPrintInfo(streams command.Streams, info info) error {
// Only append the platform info if it's not empty, to prevent printing a trailing space.
if p := info.clientPlatform(); p != "" {
_, _ = fmt.Fprintln(dockerCli.Out(), "Client:", p)
_, _ = fmt.Fprintln(streams.Out(), "Client:", p)
} else {
_, _ = fmt.Fprintln(dockerCli.Out(), "Client:")
_, _ = fmt.Fprintln(streams.Out(), "Client:")
}
if info.ClientInfo != nil {
prettyPrintClientInfo(dockerCli, *info.ClientInfo)
prettyPrintClientInfo(streams, *info.ClientInfo)
}
for _, err := range info.ClientErrors {
fmt.Fprintln(dockerCli.Err(), "ERROR:", err)
fmt.Fprintln(streams.Err(), "ERROR:", err)
}
fmt.Fprintln(dockerCli.Out())
fmt.Fprintln(dockerCli.Out(), "Server:")
fmt.Fprintln(streams.Out())
fmt.Fprintln(streams.Out(), "Server:")
if info.Info != nil {
for _, err := range prettyPrintServerInfo(dockerCli, &info) {
for _, err := range prettyPrintServerInfo(streams, &info) {
info.ServerErrors = append(info.ServerErrors, err.Error())
}
}
for _, err := range info.ServerErrors {
fmt.Fprintln(dockerCli.Err(), "ERROR:", err)
fmt.Fprintln(streams.Err(), "ERROR:", err)
}
if len(info.ServerErrors) > 0 || len(info.ClientErrors) > 0 {