diff options
author | Brent Baude <bbaude@redhat.com> | 2020-04-16 12:25:26 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-16 15:53:58 -0500 |
commit | 241326a9a8c20ad7f2bcf651416b836e7778e090 (patch) | |
tree | 4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/pod_top.go | |
parent | 88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff) | |
download | podman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.gz podman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.bz2 podman-241326a9a8c20ad7f2bcf651416b836e7778e090.zip |
Podman V2 birth
remote podman v1 and replace with podman v2.
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/pod_top.go')
-rw-r--r-- | cmd/podman/pod_top.go | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go deleted file mode 100644 index 734472817..000000000 --- a/cmd/podman/pod_top.go +++ /dev/null @@ -1,92 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - "text/tabwriter" - - "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/pkg/adapter" - "github.com/containers/libpod/pkg/util" - "github.com/pkg/errors" - "github.com/spf13/cobra" -) - -var ( - podTopCommand cliconfig.PodTopValues - - podTopDescription = fmt.Sprintf(`Specify format descriptors to alter the output. - - You may run "podman pod top -l pid pcpu seccomp" to print the process ID, the CPU percentage and the seccomp mode of each process of the latest pod. -%s`, getDescriptorString()) - - _podTopCommand = &cobra.Command{ - Use: "top [flags] CONTAINER [FORMAT-DESCRIPTORS]", - Short: "Display the running processes of containers in a pod", - Long: podTopDescription, - RunE: func(cmd *cobra.Command, args []string) error { - podTopCommand.InputArgs = args - podTopCommand.GlobalFlags = MainGlobalOpts - podTopCommand.Remote = remoteclient - return podTopCmd(&podTopCommand) - }, - Example: `podman top ctrID - podman top --latest - podman top --latest pid seccomp args %C`, - } -) - -func init() { - podTopCommand.Command = _podTopCommand - podTopCommand.SetHelpTemplate(HelpTemplate()) - podTopCommand.SetUsageTemplate(UsageTemplate()) - flags := podTopCommand.Flags() - flags.BoolVarP(&podTopCommand.Latest, "latest", "l", false, "Act on the latest pod podman is aware of") - flags.BoolVar(&podTopCommand.ListDescriptors, "list-descriptors", false, "") - markFlagHidden(flags, "list-descriptors") -} - -func podTopCmd(c *cliconfig.PodTopValues) error { - var ( - descriptors []string - ) - args := c.InputArgs - - if c.ListDescriptors { - descriptors, err := util.GetContainerPidInformationDescriptors() - if err != nil { - return err - } - fmt.Println(strings.Join(descriptors, "\n")) - return nil - } - - if len(args) < 1 && !c.Latest { - return errors.Errorf("you must provide the name or id of a running pod") - } - - runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) - if err != nil { - return errors.Wrapf(err, "error creating libpod runtime") - } - defer runtime.DeferredShutdown(false) - - if c.Latest { - descriptors = args - } else { - descriptors = args[1:] - } - - w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0) - psOutput, err := runtime.PodTop(c, descriptors) - if err != nil { - return err - } - for _, proc := range psOutput { - if _, err := fmt.Fprintln(w, proc); err != nil { - return err - } - } - return w.Flush() -} |