summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-19 11:00:59 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 16:31:34 -0400
commit7b188f7b5b28ea04bcda1747f1869a50ac4b6f4a (patch)
tree7a5678be650894dd40275dfccc3fd5b948a32112 /cmd/podman
parent17171aecf449c0f0823d7843242d735caaad7739 (diff)
downloadpodman-7b188f7b5b28ea04bcda1747f1869a50ac4b6f4a.tar.gz
podman-7b188f7b5b28ea04bcda1747f1869a50ac4b6f4a.tar.bz2
podman-7b188f7b5b28ea04bcda1747f1869a50ac4b6f4a.zip
podman version --format ... was not working
This patch fixes the podman --version --format command. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/system/version.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/cmd/podman/system/version.go b/cmd/podman/system/version.go
index b7fa289a5..92a3225b6 100644
--- a/cmd/podman/system/version.go
+++ b/cmd/podman/system/version.go
@@ -7,6 +7,7 @@ import (
"strings"
"text/tabwriter"
+ "github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/libpod/define"
@@ -51,6 +52,17 @@ func version(cmd *cobra.Command, args []string) error {
if !strings.HasSuffix(versionFormat, "\n") {
versionFormat += "\n"
}
+ out := formats.StdoutTemplate{Output: versions, Template: versionFormat}
+ err := out.Out()
+ if err != nil {
+ // On Failure, assume user is using older version of podman version --format and check client
+ versionFormat = strings.Replace(versionFormat, ".Server.", ".", 1)
+ out = formats.StdoutTemplate{Output: versions.Client, Template: versionFormat}
+ if err1 := out.Out(); err1 != nil {
+ return err
+ }
+ }
+ return nil
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
@@ -73,7 +85,7 @@ func version(cmd *cobra.Command, args []string) error {
func formatVersion(writer io.Writer, version *define.Version) {
fmt.Fprintf(writer, "Version:\t%s\n", version.Version)
- fmt.Fprintf(writer, "RemoteAPI Version:\t%d\n", version.RemoteAPIVersion)
+ fmt.Fprintf(writer, "API Version:\t%d\n", version.APIVersion)
fmt.Fprintf(writer, "Go Version:\t%s\n", version.GoVersion)
if version.GitCommit != "" {
fmt.Fprintf(writer, "Git Commit:\t%s\n", version.GitCommit)