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 <yong.tang.github@outlook.com>
Upstream-commit: 2cd4ba1e56222a938b2edaa7ad7981c9a2bc248f
Component: engine
This commit is contained in:
@@ -917,3 +917,10 @@ func (s *DockerSuite) TestPsFilterMissingArgErrorCode(c *check.C) {
|
||||
_, errCode, _ := dockerCmdWithError("ps", "--filter")
|
||||
c.Assert(errCode, checker.Equals, 125)
|
||||
}
|
||||
|
||||
// Test case for 30291
|
||||
func (s *DockerSuite) TestPsFormatTemplateWithArg(c *check.C) {
|
||||
runSleepingContainer(c, "-d", "--name", "top", "--label", "some.label=label.foo-bar")
|
||||
out, _ := dockerCmd(c, "ps", "--format", `{{.Names}} {{.Label "some.label"}}`)
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "top label.foo-bar")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user