Merge pull request #30291 from yongtang/30279-ps-format
Fix failure in `docker ps --format` when `.Label` has args
This commit is contained in:
commit
42d25de1b7
2 changed files with 13 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue