mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
compose top: ensure CMD is right-most column
Signed-off-by: Dominik Menke <dom@digineo.de>
This commit is contained in:
parent
375a279785
commit
80e8fda14f
@ -101,6 +101,21 @@ func collectTop(containers []api.ContainerProcSummary) (topHeader, []topEntries)
|
|||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure CMD is the right-most column
|
||||||
|
if pos, ok := header["CMD"]; ok {
|
||||||
|
max := pos
|
||||||
|
for h, i := range header {
|
||||||
|
if i > max {
|
||||||
|
max = i
|
||||||
|
}
|
||||||
|
if i > pos {
|
||||||
|
header[h] = i - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header["CMD"] = max
|
||||||
|
}
|
||||||
|
|
||||||
return header, entries
|
return header, entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +245,8 @@ func TestRunTopCore(t *testing.T) {
|
|||||||
"STIME": 6,
|
"STIME": 6,
|
||||||
"TTY": 7,
|
"TTY": 7,
|
||||||
"TIME": 8,
|
"TIME": 8,
|
||||||
"CMD": 9,
|
"GID": 9,
|
||||||
"GID": 10,
|
"CMD": 10,
|
||||||
}, header)
|
}, header)
|
||||||
assert.EqualValues(t, []topEntries{
|
assert.EqualValues(t, []topEntries{
|
||||||
{
|
{
|
||||||
@ -311,12 +311,12 @@ func TestRunTopCore(t *testing.T) {
|
|||||||
err := topPrint(&buf, header, entries)
|
err := topPrint(&buf, header, entries)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, trim(`
|
assert.Equal(t, trim(`
|
||||||
SERVICE # UID PID PPID C STIME TTY TIME CMD GID
|
SERVICE # UID PID PPID C STIME TTY TIME GID CMD
|
||||||
simple 1 root 1 1 0 12:00 ? 00:00:01 /entrypoint -
|
simple 1 root 1 1 0 12:00 ? 00:00:01 - /entrypoint
|
||||||
noppid 1 root 1 - 0 12:00 ? 00:00:02 /entrypoint -
|
noppid 1 root 1 - 0 12:00 ? 00:00:02 - /entrypoint
|
||||||
extra-hdr 1 root 1 1 0 12:00 ? 00:00:03 /entrypoint 1
|
extra-hdr 1 root 1 1 0 12:00 ? 00:00:03 1 /entrypoint
|
||||||
multiple 1 root 1 1 0 12:00 ? 00:00:04 /entrypoint -
|
multiple 1 root 1 1 0 12:00 ? 00:00:04 - /entrypoint
|
||||||
multiple 1 root 123 1 0 12:00 ? 00:00:42 sleep infinity -
|
multiple 1 root 123 1 0 12:00 ? 00:00:42 - sleep infinity
|
||||||
`), buf.String())
|
`), buf.String())
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user