aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorBoaz Shuster <boaz.shuster.github@gmail.com>2020-05-20 16:23:26 +0300
committerBoaz Shuster <boaz.shuster.github@gmail.com>2020-05-27 09:48:38 +0300
commit1f8a78747aebf9c597f2bd93db5fc4c074286d38 (patch)
treedee5dc589ce3aaa7b950dda9fd4b34194933084e /cmd/podman
parent1077d2d0b72d027a01080c0d3ebdb7d99a969661 (diff)
downloadpodman-1f8a78747aebf9c597f2bd93db5fc4c074286d38.tar.gz
podman-1f8a78747aebf9c597f2bd93db5fc4c074286d38.tar.bz2
podman-1f8a78747aebf9c597f2bd93db5fc4c074286d38.zip
Add --format to pod inspect
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/pods/inspect.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index 1e333247b..34c07c11b 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
@@ -36,6 +37,7 @@ func init() {
})
flags := inspectCmd.Flags()
flags.BoolVarP(&inspectOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
+ flags.StringVarP(&inspectOptions.Format, "format", "f", "json", "Format the output to a Go template or json")
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
}
@@ -54,10 +56,11 @@ func inspect(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- b, err := json.MarshalIndent(responses, "", " ")
- 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}
}
- fmt.Println(string(b))
- return nil
+
+ return out.Out()
}