Docker ps default format should not take precedence over cli flags.
This happens effectively for other flags except `-q`.
We need to let the cli to set the format as table to print the
expected output with `-q`.
Signed-off-by: David Calavera <david.calavera@gmail.com>
| ... | ... |
@@ -2,7 +2,10 @@ package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ "io/ioutil" |
|
| 6 |
+ "os" |
|
| 5 | 7 |
"os/exec" |
| 8 |
+ "path/filepath" |
|
| 6 | 9 |
"reflect" |
| 7 | 10 |
"strconv" |
| 8 | 11 |
"strings" |
| ... | ... |
@@ -554,3 +557,23 @@ func (s *DockerSuite) TestPsFormatHeaders(c *check.C) {
|
| 554 | 554 |
c.Fatalf(`Expected 'NAMES\ntest\n', got %v`, out) |
| 555 | 555 |
} |
| 556 | 556 |
} |
| 557 |
+ |
|
| 558 |
+func (s *DockerSuite) TestPsDefaultFormatAndQuiet(c *check.C) {
|
|
| 559 |
+ config := `{
|
|
| 560 |
+ "psFormat": "{{ .ID }} default"
|
|
| 561 |
+}` |
|
| 562 |
+ d, err := ioutil.TempDir("", "integration-cli-")
|
|
| 563 |
+ c.Assert(err, check.IsNil) |
|
| 564 |
+ defer os.RemoveAll(d) |
|
| 565 |
+ |
|
| 566 |
+ err = ioutil.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644) |
|
| 567 |
+ c.Assert(err, check.IsNil) |
|
| 568 |
+ |
|
| 569 |
+ out, _ := dockerCmd(c, "run", "--name=test", "-d", "busybox", "top") |
|
| 570 |
+ id := strings.TrimSpace(out) |
|
| 571 |
+ |
|
| 572 |
+ out, _ = dockerCmd(c, "--config", d, "ps", "-q") |
|
| 573 |
+ if !strings.HasPrefix(id, strings.TrimSpace(out)) {
|
|
| 574 |
+ c.Fatalf("Expected to print only the container id, got %v\n", out)
|
|
| 575 |
+ } |
|
| 576 |
+} |