mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Merge pull request #2688 from baude/issue2671
support GO template {{ json . }}
This commit is contained in:
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
@ -43,6 +44,9 @@ func versionCmd(c *cliconfig.VersionValues) error {
|
||||
|
||||
versionOutputFormat := c.Format
|
||||
if versionOutputFormat != "" {
|
||||
if strings.Join(strings.Fields(versionOutputFormat), "") == "{{json.}}" {
|
||||
versionOutputFormat = formats.JSONString
|
||||
}
|
||||
var out formats.Writer
|
||||
switch versionOutputFormat {
|
||||
case formats.JSONString:
|
||||
|
@ -36,4 +36,24 @@ var _ = Describe("Podman version", func() {
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 2))
|
||||
})
|
||||
|
||||
It("podman version --format json", func() {
|
||||
session := podmanTest.Podman([]string{"version", "--format", "json"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
||||
})
|
||||
|
||||
It("podman version --format json", func() {
|
||||
session := podmanTest.Podman([]string{"version", "--format", "{{ json .}}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
Expect(session.IsJSONOutputValid()).To(BeTrue())
|
||||
})
|
||||
|
||||
It("podman version --format GO template", func() {
|
||||
session := podmanTest.Podman([]string{"version", "--format", "{{ .Version }}"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user