summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-08-08 13:08:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-09 11:06:32 +0000
commit06fafe4cd04f29ee19078d6e78fdd792f2c1a37e (patch)
tree858649113e849d6b6c179126eb3b8740b0d2ee9d /cmd/podman
parent879453eaf16675f732dd87fd250ccaaac72f4285 (diff)
downloadpodman-06fafe4cd04f29ee19078d6e78fdd792f2c1a37e.tar.gz
podman-06fafe4cd04f29ee19078d6e78fdd792f2c1a37e.tar.bz2
podman-06fafe4cd04f29ee19078d6e78fdd792f2c1a37e.zip
add podman pod inspect
first pass of podman pod inspect Signed-off-by: baude <bbaude@redhat.com> Closes: #1236 Approved by: rhatdan
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/pod.go1
-rw-r--r--cmd/podman/pod_inspect.go65
2 files changed, 66 insertions, 0 deletions
diff --git a/cmd/podman/pod.go b/cmd/podman/pod.go
index ed79f0711..a298ca32b 100644
--- a/cmd/podman/pod.go
+++ b/cmd/podman/pod.go
@@ -11,6 +11,7 @@ Pods are a group of one or more containers sharing the same network, pid and ipc
`
podSubCommands = []cli.Command{
podCreateCommand,
+ podInspectCommand,
podKillCommand,
podPauseCommand,
podPsCommand,
diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go
new file mode 100644
index 000000000..6935335a6
--- /dev/null
+++ b/cmd/podman/pod_inspect.go
@@ -0,0 +1,65 @@
+package main
+
+import (
+ "encoding/json"
+
+ "fmt"
+ "github.com/pkg/errors"
+ "github.com/projectatomic/libpod/cmd/podman/libpodruntime"
+ "github.com/projectatomic/libpod/libpod"
+ "github.com/urfave/cli"
+)
+
+var (
+ podInspectFlags = []cli.Flag{
+ LatestPodFlag,
+ }
+ podInspectDescription = "display the configuration for a pod by name or id"
+ podInspectCommand = cli.Command{
+ Name: "inspect",
+ Usage: "displays a pod configuration",
+ Description: podInspectDescription,
+ Flags: podInspectFlags,
+ Action: podInspectCmd,
+ UseShortOptionHandling: true,
+ ArgsUsage: "[POD_NAME_OR_ID]",
+ }
+)
+
+func podInspectCmd(c *cli.Context) error {
+ var (
+ pod *libpod.Pod
+ )
+ if err := checkMutuallyExclusiveFlags(c); err != nil {
+ return err
+ }
+ args := c.Args()
+ runtime, err := libpodruntime.GetRuntime(c)
+ if err != nil {
+ return errors.Wrapf(err, "could not get runtime")
+ }
+ defer runtime.Shutdown(false)
+
+ if c.Bool("latest") {
+ pod, err = runtime.GetLatestPod()
+ if err != nil {
+ return errors.Wrapf(err, "unable to get latest pod")
+ }
+ } else {
+ pod, err = runtime.LookupPod(args[0])
+ if err != nil {
+ return err
+ }
+ }
+
+ podInspectData, err := pod.Inspect()
+ if err != nil {
+ return err
+ }
+ b, err := json.MarshalIndent(&podInspectData, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(b))
+ return nil
+}