From 13b05ea47648ee9a8d77de21d6558907fd3d3666 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 29 Oct 2018 12:08:41 -0500 Subject: Use two spaces to pad PS fields Ed has asked that we revert to using two spaces for padding between PS fields. I assume this is for docker autotests. Signed-off-by: baude --- cmd/podman/ps.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/podman') diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index d63618e58..00620b95b 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -329,7 +329,7 @@ func psCmd(c *cli.Context) error { } // Define a tab writer with stdout as the output - w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) + w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) defer w.Flush() // Output standard PS headers -- cgit v1.2.3-54-g00ecf From 058f0e36818bbb6420e21966507b1b933b5a4e41 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 29 Oct 2018 14:33:32 -0500 Subject: make various changes to ps output for backwards compatibility and auto-test, we needed a few changes that slipped in when i reworked ps to be faster to be reverted. the follow behaviours were reverted: 1. the is_infra column was redacted. that appears to be a mistake on my part. 2. a newline after ps prints its format was added 3. a newline prior to printing the headers was removed. Signed-off-by: baude --- cmd/podman/ps.go | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index d63618e58..b98ff5ef8 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -334,11 +334,7 @@ func psCmd(c *cli.Context) error { // Output standard PS headers if !opts.Namespace { - fmt.Fprintf(w, "\n%s\t%s\t%s\t%s\t%s\t%s\t%s", hid, himage, hcommand, hcreated, hstatus, hports, hnames) - // If the user does not want size OR pod info, we print the isInfra bool - if !opts.Size && !opts.Pod { - fmt.Fprintf(w, "\t%s", hinfra) - } + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s", hid, himage, hcommand, hcreated, hstatus, hports, hnames) // User wants pod info if opts.Pod { fmt.Fprintf(w, "\t%s", hpod) @@ -349,22 +345,15 @@ func psCmd(c *cli.Context) error { } } else { // Output Namespace headers - fmt.Fprintf(w, "\n%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", hid, hnames, nspid, nscgroup, nsipc, nsmnt, nsnet, nspidns, nsuserns, nsuts) - } - if len(pss) == 0 { - fmt.Fprint(w, "\n") + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", hid, hnames, nspid, nscgroup, nsipc, nsmnt, nsnet, nspidns, nsuserns, nsuts) } + // Now iterate each container and output its information for _, container := range pss { // Standard PS output if !opts.Namespace { fmt.Fprintf(w, "\n%s\t%s\t%s\t%s\t%s\t%s\t%s", container.ID, container.Image, container.Command, container.Created, container.Status, container.Ports, container.Names) - - // If not size and not pod info, do isInfra - if !opts.Size && !opts.Pod { - fmt.Fprintf(w, "\t%t", container.IsInfra) - } // User wants pod info if opts.Pod { fmt.Fprintf(w, "\t%s", container.Pod) @@ -387,6 +376,7 @@ func psCmd(c *cli.Context) error { } } + fmt.Fprint(w, "\n") return nil } -- cgit v1.2.3-54-g00ecf From aa49675e294f075ae98141327246ec08ae84b512 Mon Sep 17 00:00:00 2001 From: baude Date: Tue, 30 Oct 2018 08:17:04 -0500 Subject: truncate command output in ps by default when the PS command was reworked for performance and formatting improvements, i forgot to truncate the command field. Long container commands was throwing the formatting off. we now truncated to 17 characters plus the elipses. Signed-off-by: baude --- cmd/podman/shared/container.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cmd/podman') diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go index b847314a4..4404268d4 100644 --- a/cmd/podman/shared/container.go +++ b/cmd/podman/shared/container.go @@ -24,6 +24,7 @@ import ( const ( cidTruncLength = 12 podTruncLength = 12 + cmdTruncLength = 17 ) // PsOptions describes the struct being formed for ps @@ -191,9 +192,12 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput pod := ctr.PodID() if !opts.NoTrunc { cid = cid[0:cidTruncLength] - if len(pod) > 12 { + if len(pod) > podTruncLength { pod = pod[0:podTruncLength] } + if len(command) > cmdTruncLength { + command = command[0:cmdTruncLength] + "..." + } } pso.ID = cid -- cgit v1.2.3-54-g00ecf