mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #9131 from vieux/empty_lines_dockerinfo
Do not display empty lines in docker info if the key doesn't exists
This commit is contained in:
commit
967354d488
1 changed files with 40 additions and 20 deletions
|
@ -473,20 +473,33 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
}
|
}
|
||||||
out.Close()
|
out.Close()
|
||||||
|
|
||||||
fmt.Fprintf(cli.out, "Containers: %d\n", remoteInfo.GetInt("Containers"))
|
if remoteInfo.Exists("Containers") {
|
||||||
fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images"))
|
fmt.Fprintf(cli.out, "Containers: %d\n", remoteInfo.GetInt("Containers"))
|
||||||
fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver"))
|
|
||||||
var driverStatus [][2]string
|
|
||||||
if err := remoteInfo.GetJson("DriverStatus", &driverStatus); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
for _, pair := range driverStatus {
|
if remoteInfo.Exists("Images") {
|
||||||
fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1])
|
fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("Driver") {
|
||||||
|
fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("DriverStatus") {
|
||||||
|
var driverStatus [][2]string
|
||||||
|
if err := remoteInfo.GetJson("DriverStatus", &driverStatus); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, pair := range driverStatus {
|
||||||
|
fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("ExecutionDriver") {
|
||||||
|
fmt.Fprintf(cli.out, "Execution Driver: %s\n", remoteInfo.Get("ExecutionDriver"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("KernelVersion") {
|
||||||
|
fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("OperatingSystem") {
|
||||||
|
fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(cli.out, "Execution Driver: %s\n", remoteInfo.Get("ExecutionDriver"))
|
|
||||||
fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
|
||||||
fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
|
||||||
|
|
||||||
if remoteInfo.Exists("NCPU") {
|
if remoteInfo.Exists("NCPU") {
|
||||||
fmt.Fprintf(cli.out, "CPUs: %d\n", remoteInfo.GetInt("NCPU"))
|
fmt.Fprintf(cli.out, "CPUs: %d\n", remoteInfo.GetInt("NCPU"))
|
||||||
}
|
}
|
||||||
|
@ -495,12 +508,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
||||||
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
|
if remoteInfo.Exists("Debug") {
|
||||||
|
fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
|
||||||
|
}
|
||||||
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
|
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
|
||||||
fmt.Fprintf(cli.out, "Fds: %d\n", remoteInfo.GetInt("NFd"))
|
if remoteInfo.Exists("NFd") {
|
||||||
fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines"))
|
fmt.Fprintf(cli.out, "Fds: %d\n", remoteInfo.GetInt("NFd"))
|
||||||
fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
|
}
|
||||||
|
if remoteInfo.Exists("NGoroutines") {
|
||||||
|
fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines"))
|
||||||
|
}
|
||||||
|
if remoteInfo.Exists("NEventsListener") {
|
||||||
|
fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
|
||||||
|
}
|
||||||
if initSha1 := remoteInfo.Get("InitSha1"); initSha1 != "" {
|
if initSha1 := remoteInfo.Get("InitSha1"); initSha1 != "" {
|
||||||
fmt.Fprintf(cli.out, "Init SHA1: %s\n", initSha1)
|
fmt.Fprintf(cli.out, "Init SHA1: %s\n", initSha1)
|
||||||
}
|
}
|
||||||
|
@ -517,13 +537,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
fmt.Fprintf(cli.out, "Registry: %v\n", remoteInfo.GetList("IndexServerAddress"))
|
fmt.Fprintf(cli.out, "Registry: %v\n", remoteInfo.GetList("IndexServerAddress"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !remoteInfo.GetBool("MemoryLimit") {
|
if remoteInfo.Exists("MemoryLimit") && !remoteInfo.GetBool("MemoryLimit") {
|
||||||
fmt.Fprintf(cli.err, "WARNING: No memory limit support\n")
|
fmt.Fprintf(cli.err, "WARNING: No memory limit support\n")
|
||||||
}
|
}
|
||||||
if !remoteInfo.GetBool("SwapLimit") {
|
if remoteInfo.Exists("SwapLimit") && !remoteInfo.GetBool("SwapLimit") {
|
||||||
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n")
|
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n")
|
||||||
}
|
}
|
||||||
if !remoteInfo.GetBool("IPv4Forwarding") {
|
if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") {
|
||||||
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
|
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue