summaryrefslogtreecommitdiff
path: root/cmd/podman/pods/inspect.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-10-07 10:24:59 -0700
committerJhon Honce <jhonce@redhat.com>2020-10-08 07:42:07 -0700
commit3cca814eb3cdf2dd8ef2df90a52a6cd0608ac4b6 (patch)
tree980c5dc45b83aa731052170462af7d202ae879f9 /cmd/podman/pods/inspect.go
parent59b5f0ac32ddf615fada021bc62c823bb73233da (diff)
downloadpodman-3cca814eb3cdf2dd8ef2df90a52a6cd0608ac4b6.tar.gz
podman-3cca814eb3cdf2dd8ef2df90a52a6cd0608ac4b6.tar.bz2
podman-3cca814eb3cdf2dd8ef2df90a52a6cd0608ac4b6.zip
Restore --format 'table...' to commands
* podman xyz inspect Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/pods/inspect.go')
-rw-r--r--cmd/podman/pods/inspect.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index bc20352b0..cad15d10f 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -3,9 +3,13 @@ package pods
import (
"context"
"fmt"
+ "os"
+ "text/tabwriter"
+ "text/template"
- "github.com/containers/buildah/pkg/formats"
+ "github.com/containers/podman/v2/cmd/podman/parse"
"github.com/containers/podman/v2/cmd/podman/registry"
+ "github.com/containers/podman/v2/cmd/podman/report"
"github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
@@ -57,11 +61,19 @@ func inspect(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- var data interface{} = responses
- var out formats.Writer = formats.JSONStruct{Output: data}
- if inspectOptions.Format != "json" {
- out = formats.StdoutTemplate{Output: data, Template: inspectOptions.Format}
+
+ if parse.MatchesJSONFormat(inspectOptions.Format) {
+ enc := json.NewEncoder(os.Stdout)
+ return enc.Encode(responses)
+ }
+
+ row := report.NormalizeFormat(inspectOptions.Format)
+
+ t, err := template.New("pod inspect").Parse(row)
+ if err != nil {
+ return err
}
- return out.Out()
+ w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
+ return t.Execute(w, *responses)
}