mirror of
https://github.com/containers/podman.git
synced 2025-06-02 19:02:10 +08:00
Merge pull request #4408 from slimjim2234/master
Fixed issue #4391; podman info --format '{{ json . }}'
This commit is contained in:
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
rt "runtime"
|
rt "runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/buildah/pkg/formats"
|
"github.com/containers/buildah/pkg/formats"
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
@ -88,6 +89,9 @@ func infoCmd(c *cliconfig.InfoValues) error {
|
|||||||
|
|
||||||
var out formats.Writer
|
var out formats.Writer
|
||||||
infoOutputFormat := c.Format
|
infoOutputFormat := c.Format
|
||||||
|
if strings.Join(strings.Fields(infoOutputFormat), "") == "{{json.}}" {
|
||||||
|
infoOutputFormat = formats.JSONString
|
||||||
|
}
|
||||||
switch infoOutputFormat {
|
switch infoOutputFormat {
|
||||||
case formats.JSONString:
|
case formats.JSONString:
|
||||||
out = formats.JSONStruct{Output: info}
|
out = formats.JSONStruct{Output: info}
|
||||||
|
@ -45,4 +45,10 @@ var _ = Describe("Podman Info", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
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())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user