From ba1871dac033783ab0329c9b3c9113a34a90992f Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 19 Jul 2018 14:41:58 +0200 Subject: podman-top: use containers/psgo Use github.com/containers/psgo instead of execing `ps (1)`. The psgo library enables a much more flexible interface with respect to which data to be printed (e.g., capabilities, seccomp mode, PID, PCPU, etc.) while the output can be parsed reliably. The library does not use ps (1) but parses /proc and /dev instead. To list the processes of a given container, psgo will join the mount namespace of the given container and extract all data from there. Notice that this commit breaks compatibility with docker-top. Signed-off-by: Valentin Rothberg Closes: #1113 Approved by: rhatdan --- completions/bash/podman | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'completions/bash/podman') diff --git a/completions/bash/podman b/completions/bash/podman index b01a30aaa..424370904 100644 --- a/completions/bash/podman +++ b/completions/bash/podman @@ -1809,6 +1809,14 @@ _podman_tag() { esac } +__podman_top_descriptors() { + podman top --list-descriptors +} + +__podman_complete_top_descriptors() { + COMPREPLY=($(compgen -W "$(__podman_top_descriptors)" -- "$cur")) +} + _podman_top() { local options_with_args=" " @@ -1818,6 +1826,14 @@ _podman_top() { --latest -l " + + # podman-top works on only *one* container, which means that when we have + # three or more arguments, we can complete with top descriptors. + if [[ "${COMP_CWORD}" -ge 3 ]]; then + __podman_complete_top_descriptors + return + fi + case "$cur" in -*) COMPREPLY=($(compgen -W "$boolean_options $options_with_args" -- "$cur")) -- cgit v1.2.3-54-g00ecf