From a2afbcbb57a25009081c9cd867416a98215baecd Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 19 Jan 2017 10:17:56 -0800 Subject: [PATCH] Fix failure in `docker ps --format` when `.Label` has args This fix tries to fix the issue in 30279 where `docker ps --format` fails if `.Label` has args. For example: ``` docker ps --format '{{.ID}}\t{{.Names}}\t{{.Label "some.label"}}' ``` The reason for the failure is that during the preprocessing phase to detect the existance of `.Size`, the `listOptionsProcessor` does not has a method of `Label(name string) string`. This results in the failure of ``` template: :1:24: executing "" at <.Label>: Label is not a method but has arguments ``` This fix fixes the issue by adding needed method of `Label(name string) string`. This fix fixes 30279. Signed-off-by: Yong Tang --- command/container/list.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/command/container/list.go b/command/container/list.go index 451c531a8b..e0f4fdf21f 100644 --- a/command/container/list.go +++ b/command/container/list.go @@ -73,6 +73,12 @@ func (o listOptionsProcessor) Size() bool { return true } +// Label is needed here as it allows the correct pre-processing +// because Label() is a method with arguments +func (o listOptionsProcessor) Label(name string) string { + return "" +} + func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, error) { options := &types.ContainerListOptions{ All: opts.all,