summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/pod_inspect.go9
-rw-r--r--cmd/podman/pod_top.go26
-rw-r--r--cmd/podman/tree.go2
4 files changed, 35 insertions, 3 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index b130f3232..ef300ef75 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -76,6 +76,7 @@ var cmdsNotRequiringRootless = map[*cobra.Command]bool{
_podKillCommand: true,
_podStatsCommand: true,
_podStopCommand: true,
+ _podTopCommand: true,
_restartCommand: true,
_rmCommand: true,
_runCommand: true,
diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go
index 79ffe2e6f..851f39aa0 100644
--- a/cmd/podman/pod_inspect.go
+++ b/cmd/podman/pod_inspect.go
@@ -14,7 +14,7 @@ var (
podInspectCommand cliconfig.PodInspectValues
podInspectDescription = `Display the configuration for a pod by name or id
- By default, this will render all results in a JSON array. If the container and image have the same name, this command returns the container JSON.`
+ By default, this will render all results in a JSON array.`
_podInspectCommand = &cobra.Command{
Use: "inspect [flags] POD",
@@ -34,7 +34,7 @@ func init() {
podInspectCommand.SetHelpTemplate(HelpTemplate())
podInspectCommand.SetUsageTemplate(UsageTemplate())
flags := podInspectCommand.Flags()
- flags.BoolVarP(&podInspectCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+ flags.BoolVarP(&podInspectCommand.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
markFlagHiddenForRemoteClient("latest", flags)
}
@@ -44,6 +44,11 @@ func podInspectCmd(c *cliconfig.PodInspectValues) error {
pod *adapter.Pod
)
args := c.InputArgs
+
+ if len(args) < 1 && !c.Latest {
+ return errors.Errorf("you must provide the name or id of a pod")
+ }
+
runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go
index c9a6d8822..f65d66df6 100644
--- a/cmd/podman/pod_top.go
+++ b/cmd/podman/pod_top.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -53,6 +54,10 @@ func podTopCmd(c *cliconfig.PodTopValues) error {
)
args := c.InputArgs
+ if os.Geteuid() != 0 {
+ rootless.SetSkipStorageSetup(true)
+ }
+
if c.ListDescriptors {
descriptors, err := libpod.GetContainerPidInformationDescriptors()
if err != nil {
@@ -77,6 +82,27 @@ func podTopCmd(c *cliconfig.PodTopValues) error {
} else {
descriptors = args[1:]
}
+
+ if os.Geteuid() != 0 {
+ var pod *adapter.Pod
+ var err error
+ if c.Latest {
+ pod, err = runtime.GetLatestPod()
+ } else {
+ pod, err = runtime.LookupPod(c.InputArgs[0])
+ }
+ if err != nil {
+ return errors.Wrapf(err, "unable to lookup requested container")
+ }
+ became, ret, err := runtime.JoinOrCreateRootlessPod(pod)
+ if err != nil {
+ return err
+ }
+ if became {
+ os.Exit(ret)
+ }
+ }
+
w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
psOutput, err := runtime.PodTop(c, descriptors)
if err != nil {
diff --git a/cmd/podman/tree.go b/cmd/podman/tree.go
index ebda18cdb..c56e35aef 100644
--- a/cmd/podman/tree.go
+++ b/cmd/podman/tree.go
@@ -23,7 +23,7 @@ var (
treeDescription = "Prints layer hierarchy of an image in a tree format"
_treeCommand = &cobra.Command{
- Use: "tree",
+ Use: "tree [flags] IMAGE",
Short: treeDescription,
Long: treeDescription,
RunE: func(cmd *cobra.Command, args []string) error {