summaryrefslogtreecommitdiff
path: root/cmd/podman/pod_top.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-06 12:24:13 -0800
committerGitHub <noreply@github.com>2019-03-06 12:24:13 -0800
commit02e2342d20a01c89236b4c2f2867e6acd8eda923 (patch)
tree8c0ecfb6f8666d80328a564106c53214f66e3e97 /cmd/podman/pod_top.go
parentf50715ed25fd1bc58dad39982a2a5b5837dcd8ef (diff)
parent788f818cc53fbd68267c2c6ab5de8655938414cb (diff)
downloadpodman-02e2342d20a01c89236b4c2f2867e6acd8eda923.tar.gz
podman-02e2342d20a01c89236b4c2f2867e6acd8eda923.tar.bz2
podman-02e2342d20a01c89236b4c2f2867e6acd8eda923.zip
Merge pull request #2442 from baude/remotepodtop
podman-remote pod top|stats
Diffstat (limited to 'cmd/podman/pod_top.go')
-rw-r--r--cmd/podman/pod_top.go31
1 files changed, 7 insertions, 24 deletions
diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go
index 6a26e3dff..c5383d376 100644
--- a/cmd/podman/pod_top.go
+++ b/cmd/podman/pod_top.go
@@ -2,13 +2,12 @@ package main
import (
"fmt"
+ "github.com/containers/libpod/pkg/adapter"
"os"
"strings"
"text/tabwriter"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -50,8 +49,9 @@ func init() {
}
func podTopCmd(c *cliconfig.PodTopValues) error {
- var pod *libpod.Pod
- var err error
+ var (
+ descriptors []string
+ )
args := c.InputArgs
if c.ListDescriptors {
@@ -67,39 +67,22 @@ func podTopCmd(c *cliconfig.PodTopValues) error {
return errors.Errorf("you must provide the name or id of a running pod")
}
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- var descriptors []string
if c.Latest {
descriptors = args
- pod, err = runtime.GetLatestPod()
} else {
descriptors = args[1:]
- pod, err = runtime.LookupPod(args[0])
}
-
- if err != nil {
- return errors.Wrapf(err, "unable to lookup requested container")
- }
-
- podStatus, err := shared.GetPodStatus(pod)
- if err != nil {
- return err
- }
- if podStatus != "Running" {
- return errors.Errorf("pod top can only be used on pods with at least one running container")
- }
-
- psOutput, err := pod.GetPodPidInformation(descriptors)
+ w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
+ psOutput, err := runtime.PodTop(c, descriptors)
if err != nil {
return err
}
-
- w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
for _, proc := range psOutput {
fmt.Fprintln(w, proc)
}