Do not display empty lines in docker info if the key doesn't exists
| ... | ... |
@@ -473,20 +473,33 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 473 | 473 |
} |
| 474 | 474 |
out.Close() |
| 475 | 475 |
|
| 476 |
- fmt.Fprintf(cli.out, "Containers: %d\n", remoteInfo.GetInt("Containers"))
|
|
| 477 |
- fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images"))
|
|
| 478 |
- fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver"))
|
|
| 479 |
- var driverStatus [][2]string |
|
| 480 |
- if err := remoteInfo.GetJson("DriverStatus", &driverStatus); err != nil {
|
|
| 481 |
- return err |
|
| 476 |
+ if remoteInfo.Exists("Containers") {
|
|
| 477 |
+ fmt.Fprintf(cli.out, "Containers: %d\n", remoteInfo.GetInt("Containers"))
|
|
| 482 | 478 |
} |
| 483 |
- for _, pair := range driverStatus {
|
|
| 484 |
- fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1]) |
|
| 479 |
+ if remoteInfo.Exists("Images") {
|
|
| 480 |
+ fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images"))
|
|
| 481 |
+ } |
|
| 482 |
+ if remoteInfo.Exists("Driver") {
|
|
| 483 |
+ fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver"))
|
|
| 484 |
+ } |
|
| 485 |
+ if remoteInfo.Exists("DriverStatus") {
|
|
| 486 |
+ var driverStatus [][2]string |
|
| 487 |
+ if err := remoteInfo.GetJson("DriverStatus", &driverStatus); err != nil {
|
|
| 488 |
+ return err |
|
| 489 |
+ } |
|
| 490 |
+ for _, pair := range driverStatus {
|
|
| 491 |
+ fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1]) |
|
| 492 |
+ } |
|
| 493 |
+ } |
|
| 494 |
+ if remoteInfo.Exists("ExecutionDriver") {
|
|
| 495 |
+ fmt.Fprintf(cli.out, "Execution Driver: %s\n", remoteInfo.Get("ExecutionDriver"))
|
|
| 496 |
+ } |
|
| 497 |
+ if remoteInfo.Exists("KernelVersion") {
|
|
| 498 |
+ fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
|
| 499 |
+ } |
|
| 500 |
+ if remoteInfo.Exists("OperatingSystem") {
|
|
| 501 |
+ fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
|
| 485 | 502 |
} |
| 486 |
- fmt.Fprintf(cli.out, "Execution Driver: %s\n", remoteInfo.Get("ExecutionDriver"))
|
|
| 487 |
- fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion"))
|
|
| 488 |
- fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem"))
|
|
| 489 |
- |
|
| 490 | 503 |
if remoteInfo.Exists("NCPU") {
|
| 491 | 504 |
fmt.Fprintf(cli.out, "CPUs: %d\n", remoteInfo.GetInt("NCPU"))
|
| 492 | 505 |
} |
| ... | ... |
@@ -495,12 +508,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 495 | 495 |
} |
| 496 | 496 |
|
| 497 | 497 |
if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" {
|
| 498 |
- fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
|
|
| 498 |
+ if remoteInfo.Exists("Debug") {
|
|
| 499 |
+ fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug"))
|
|
| 500 |
+ } |
|
| 499 | 501 |
fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "")
|
| 500 |
- fmt.Fprintf(cli.out, "Fds: %d\n", remoteInfo.GetInt("NFd"))
|
|
| 501 |
- fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines"))
|
|
| 502 |
- fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
|
|
| 503 |
- |
|
| 502 |
+ if remoteInfo.Exists("NFd") {
|
|
| 503 |
+ fmt.Fprintf(cli.out, "Fds: %d\n", remoteInfo.GetInt("NFd"))
|
|
| 504 |
+ } |
|
| 505 |
+ if remoteInfo.Exists("NGoroutines") {
|
|
| 506 |
+ fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines"))
|
|
| 507 |
+ } |
|
| 508 |
+ if remoteInfo.Exists("NEventsListener") {
|
|
| 509 |
+ fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener"))
|
|
| 510 |
+ } |
|
| 504 | 511 |
if initSha1 := remoteInfo.Get("InitSha1"); initSha1 != "" {
|
| 505 | 512 |
fmt.Fprintf(cli.out, "Init SHA1: %s\n", initSha1) |
| 506 | 513 |
} |
| ... | ... |
@@ -517,13 +537,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 517 | 517 |
fmt.Fprintf(cli.out, "Registry: %v\n", remoteInfo.GetList("IndexServerAddress"))
|
| 518 | 518 |
} |
| 519 | 519 |
} |
| 520 |
- if !remoteInfo.GetBool("MemoryLimit") {
|
|
| 520 |
+ if remoteInfo.Exists("MemoryLimit") && !remoteInfo.GetBool("MemoryLimit") {
|
|
| 521 | 521 |
fmt.Fprintf(cli.err, "WARNING: No memory limit support\n") |
| 522 | 522 |
} |
| 523 |
- if !remoteInfo.GetBool("SwapLimit") {
|
|
| 523 |
+ if remoteInfo.Exists("SwapLimit") && !remoteInfo.GetBool("SwapLimit") {
|
|
| 524 | 524 |
fmt.Fprintf(cli.err, "WARNING: No swap limit support\n") |
| 525 | 525 |
} |
| 526 |
- if !remoteInfo.GetBool("IPv4Forwarding") {
|
|
| 526 |
+ if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") {
|
|
| 527 | 527 |
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n") |
| 528 | 528 |
} |
| 529 | 529 |
return nil |