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