Skip to content

Commit

Permalink
Merge pull request containers#4408 from slimjim2234/master
Browse files Browse the repository at this point in the history
Fixed issue containers#4391; podman info --format '{{ json . }}'
  • Loading branch information
openshift-merge-robot committed Nov 8, 2019
2 parents f456ce9 + cb2978d commit b713e53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/podman/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
rt "runtime"
"strings"

"github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/cliconfig"
Expand Down Expand Up @@ -88,6 +89,9 @@ func infoCmd(c *cliconfig.InfoValues) error {

var out formats.Writer
infoOutputFormat := c.Format
if strings.Join(strings.Fields(infoOutputFormat), "") == "{{json.}}" {
infoOutputFormat = formats.JSONString
}
switch infoOutputFormat {
case formats.JSONString:
out = formats.JSONStruct{Output: info}
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,10 @@ var _ = Describe("Podman Info", func() {
Expect(session.ExitCode()).To(Equal(0))

})
It("podman info --format GO template", func() {
session := podmanTest.Podman([]string{"info", "--format", "{{ json .}}"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(session.IsJSONOutputValid()).To(BeTrue())
})
})

0 comments on commit b713e53

Please sign in to comment.