File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,10 @@ func (c *containerStatsContext) Container() string {
145
145
146
146
func (c * containerStatsContext ) Name () string {
147
147
c .AddHeader (nameHeader )
148
- name := c .s .Name [1 :]
149
- return name
148
+ if len (c .s .Name ) > 1 {
149
+ return c .s .Name [1 :]
150
+ }
151
+ return "--"
150
152
}
151
153
152
154
func (c * containerStatsContext ) ID () string {
Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ func TestContainerStatsContextWrite(t *testing.T) {
69
69
`MEM USAGE / LIMIT
70
70
20 B / 20 B
71
71
-- / --
72
+ ` ,
73
+ },
74
+ {
75
+ Context {Format : "{{.Container}} {{.ID}} {{.Name}}" },
76
+ `container1 abcdef foo
77
+ container2 --
72
78
` ,
73
79
},
74
80
{
@@ -83,6 +89,8 @@ container2 --
83
89
stats := []StatsEntry {
84
90
{
85
91
Container : "container1" ,
92
+ ID : "abcdef" ,
93
+ Name : "/foo" ,
86
94
CPUPercentage : 20 ,
87
95
Memory : 20 ,
88
96
MemoryLimit : 20 ,
You can’t perform that action at this time.
0 commit comments