moby/cli/command/formatter
Zhang Wei 5a7b3c78e0 Fix panic of "docker stats --format {{.Name}} --all"
This commit fixes panic when execute stats command:

* use --format {{.Name}} with --all when there're exited containers.
* use --format {{.Name}} while stating exited container.

The root cause is when stating an exited container, the result from the
api didn't contain the Name and ID field, which will make format
process panic.

Panic log is like this:

```
panic: runtime error: slice bounds out of range [recovered]
	panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0xb20f80, 0xc420014110)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
text/template.errRecover(0xc4201773e8)
	/usr/local/go/src/text/template/exec.go:140 +0x2ad
panic(0xb20f80, 0xc420014110)
	/usr/local/go/src/runtime/panic.go:458 +0x243
github.com/docker/docker/cli/command/formatter.(*containerStatsContext).Name(0xc420430160,
0x0, 0x0)
	/go/src/github.com/docker/docker/cli/command/formatter/stats.go:148
+0x86
reflect.Value.call(0xb9a3a0, 0xc420430160, 0x2213, 0xbe3657, 0x4,
0x11bc9f8, 0x0, 0x0, 0x4d75b3, 0x1198940, ...)
	/usr/local/go/src/reflect/value.go:434 +0x5c8
reflect.Value.Call(0xb9a3a0, 0xc420430160, 0x2213, 0x11bc9f8, 0x0, 0x0,
0xc420424028, 0xb, 0xb)
	/usr/local/go/src/reflect/value.go:302 +0xa4
text/template.(*state).evalCall(0xc420177368, 0xb9a3a0, 0xc420430160,
0x16, 0xb9a3a0, 0xc420430160, 0x2213, 0x1178fa0, 0xc4203ea330,
0xc4203de283, ...)
	/usr/local/go/src/text/template/exec.go:658 +0x530
```

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2017-02-08 10:26:52 +08:00
..
container.go Add Networks placeholder to ps --format 2016-10-20 07:41:56 -07:00
container_test.go Fix several issues with go vet and go fmt 2016-11-17 06:31:28 -08:00
custom.go Refactor formatter. 2016-09-13 17:58:12 -04:00
custom_test.go Move api/client -> cli/command 2016-09-08 15:46:29 -04:00
disk_usage.go Ensure proper value is used when computing reclaimable space 2017-01-23 13:57:20 -08:00
formatter.go Move templates to pkg/templates 2016-12-12 09:34:03 +01:00
image.go Merge pull request #30043 from dmcgowan/distribution-reference-update-1 2017-01-24 20:38:20 -08:00
image_test.go Generate api/types:Image from the swagger spec 2016-10-20 13:24:23 -07:00
network.go Add .CreatedAt placeholder for docker network ls --format 2017-01-04 15:18:44 -08:00
network_test.go Add .CreatedAt placeholder for docker network ls --format 2017-01-04 15:18:44 -08:00
plugin.go Add docker plugin upgrade 2017-02-03 16:21:12 -05:00
plugin_test.go Add docker plugin upgrade 2017-02-03 16:21:12 -05:00
reflect.go Fix broken JSON support in cli/command/formatter 2016-10-17 08:07:17 +00:00
reflect_test.go Fix broken JSON support in cli/command/formatter 2016-10-17 08:07:17 +00:00
service.go Add --format to docker service ls 2017-02-01 08:33:19 -08:00
service_test.go Add --format to docker service ls 2017-02-01 08:33:19 -08:00
stats.go Fix panic of "docker stats --format {{.Name}} --all" 2017-02-08 10:26:52 +08:00
stats_test.go Fix panic of "docker stats --format {{.Name}} --all" 2017-02-08 10:26:52 +08:00
volume.go Merge pull request #26519 from AkihiroSuda/fix-cli-command-formatter-json-support 2016-10-17 22:44:04 +01:00
volume_test.go Merge pull request #26519 from AkihiroSuda/fix-cli-command-formatter-json-support 2016-10-17 22:44:04 +01:00