Merge pull request #724 from gtardif/json_context_format

Allow `docker context ls —formatter {{json.}}` to not delegate to Moby and include context type in the json
This commit is contained in:
Guillaume Tardif 2020-10-06 18:12:54 +02:00 committed by GitHub
commit 6fa93db021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View file

@ -81,6 +81,12 @@ func TestContextDefault(t *testing.T) {
res = c.RunDockerCmd("context", "ls", "--format", "json")
golden.Assert(t, res.Stdout(), GoldenFile("ls-out-json"))
res = c.RunDockerCmd("context", "ls", "--json")
golden.Assert(t, res.Stdout(), GoldenFile("ls-out-json"))
res = c.RunDockerCmd("context", "ls", "--format", "{{ json . }}")
golden.Assert(t, res.Stdout(), GoldenFile("ls-out-json"))
})
t.Run("inspect", func(t *testing.T) {
@ -422,6 +428,13 @@ func TestVersion(t *testing.T) {
res.Assert(t, icmd.Expected{Out: `"Client":`})
})
t.Run("format legacy", func(t *testing.T) {
res := c.RunDockerCmd("version", "-f", "{{ json .Client }}")
res.Assert(t, icmd.Expected{Out: `"DefaultAPIVersion":`})
res = c.RunDockerCmd("version", "--format", "{{ json .Server }}")
res.Assert(t, icmd.Expected{Out: `"KernelVersion":`})
})
t.Run("format cloud integration", func(t *testing.T) {
res := c.RunDockerCmd("version", "-f", "pretty")
res.Assert(t, icmd.Expected{Out: `Cloud integration:`})