diff options
author | Yong Tang <yong.tang.github@outlook.com> | 2016-11-22 16:23:21 -0800 |
---|---|---|
committer | Yong Tang <yong.tang.github@outlook.com> | 2017-01-20 15:59:44 -0800 |
commit | 1c0d37fa7f04ade13e65aff74ea0495bb846d782 (patch) | |
tree | ddfa7b105f678881837381285d6b0c74e4603056 /integration-cli/docker_cli_plugins_test.go | |
parent | 7a97705b52e7f5c65d31870579cb1dcc09506d89 (diff) | |
download | docker-1c0d37fa7f04ade13e65aff74ea0495bb846d782.tar.gz |
Add `--format` flag for `docker plugin ls`
This fix tries to address the enhancement discussed in 28735 to add
`--format` for the output of `docker plugin ls`.
This fix
1. Add `--format` and `--quiet` flags to `docker plugin ls`
2. Convert the current implementation to use `formatter`, consistent with
other docker list commands.
3. Add `pluginsFormat` for config.json.
Related docs has been updated.
Several unit tests have been added to cover the changes.
This fix is related to 28708 and 28735.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'integration-cli/docker_cli_plugins_test.go')
-rw-r--r-- | integration-cli/docker_cli_plugins_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/integration-cli/docker_cli_plugins_test.go b/integration-cli/docker_cli_plugins_test.go index 0f07e8b45b..e294fffd19 100644 --- a/integration-cli/docker_cli_plugins_test.go +++ b/integration-cli/docker_cli_plugins_test.go @@ -401,3 +401,29 @@ func (s *DockerSuite) TestPluginIDPrefix(c *check.C) { c.Assert(out, checker.Not(checker.Contains), pName) c.Assert(out, checker.Not(checker.Contains), pTag) } + +func (s *DockerSuite) TestPluginListDefaultFormat(c *check.C) { + testRequires(c, DaemonIsLinux, Network, IsAmd64) + + config, err := ioutil.TempDir("", "config-file-") + c.Assert(err, check.IsNil) + defer os.RemoveAll(config) + + err = ioutil.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0644) + c.Assert(err, check.IsNil) + + out, _ := dockerCmd(c, "plugin", "install", "--grant-all-permissions", pName) + c.Assert(strings.TrimSpace(out), checker.Contains, pName) + + out, _ = dockerCmd(c, "plugin", "inspect", "--format", "{{.ID}}", pNameWithTag) + id := strings.TrimSpace(out) + + // We expect the format to be in `raw + --no-trunc` + expectedOutput := fmt.Sprintf(`plugin_id: %s +name: %s +description: A sample volume plugin for Docker +enabled: true`, id, pNameWithTag) + + out, _ = dockerCmd(c, "--config", config, "plugin", "ls", "--no-trunc") + c.Assert(strings.TrimSpace(out), checker.Contains, expectedOutput) +} |