summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-06 15:23:19 +0200
committerGitHub <noreply@github.com>2020-04-06 15:23:19 +0200
commitba64186750a23675f42744ca4203b524e7b1b378 (patch)
tree018be18b7e1f9dec076120ab2d9ca65a56eebb10 /cmd
parent8dea3c3419629de432bfaaa03d785fdb63b902d5 (diff)
parent7cbc09971a4d7322a6b29d86ef1d1fcb71f68f04 (diff)
downloadpodman-ba64186750a23675f42744ca4203b524e7b1b378.tar.gz
podman-ba64186750a23675f42744ca4203b524e7b1b378.tar.bz2
podman-ba64186750a23675f42744ca4203b524e7b1b378.zip
Merge pull request #5689 from sujil02/v2-pod-inspect
podmanv2 pod inspect
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podmanV2/pods/inspect.go64
1 files changed, 64 insertions, 0 deletions
diff --git a/cmd/podmanV2/pods/inspect.go b/cmd/podmanV2/pods/inspect.go
new file mode 100644
index 000000000..9aab610f2
--- /dev/null
+++ b/cmd/podmanV2/pods/inspect.go
@@ -0,0 +1,64 @@
+package pods
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podmanV2/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ jsoniter "github.com/json-iterator/go"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ inspectOptions = entities.PodInspectOptions{}
+)
+
+var (
+ inspectDescription = fmt.Sprintf(`Display the configuration for a pod by name or id
+
+ By default, this will render all results in a JSON array.`)
+
+ inspectCmd = &cobra.Command{
+ Use: "inspect [flags] POD [POD...]",
+ Short: "Displays a pod configuration",
+ Long: inspectDescription,
+ RunE: inspect,
+ Example: `podman pod inspect podID`,
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: inspectCmd,
+ Parent: podCmd,
+ })
+ flags := inspectCmd.Flags()
+ flags.BoolVarP(&inspectOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
+ if registry.IsRemote() {
+ _ = flags.MarkHidden("latest")
+ }
+}
+
+func inspect(cmd *cobra.Command, args []string) error {
+
+ if len(args) < 1 && !inspectOptions.Latest {
+ return errors.Errorf("you must provide the name or id of a running pod")
+ }
+
+ if !inspectOptions.Latest {
+ inspectOptions.NameOrID = args[0]
+ }
+ responses, err := registry.ContainerEngine().PodInspect(context.Background(), inspectOptions)
+ if err != nil {
+ return err
+ }
+ b, err := jsoniter.MarshalIndent(responses, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(b))
+ return nil
+}