summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_top_linux.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go
index 450130add..9b0f156b5 100644
--- a/libpod/container_top_linux.go
+++ b/libpod/container_top_linux.go
@@ -6,7 +6,7 @@ import (
"strconv"
"strings"
- "github.com/containers/psgo/ps"
+ "github.com/containers/psgo"
)
// GetContainerPidInformation returns process-related data of all processes in
@@ -19,12 +19,23 @@ import (
// For more details, please refer to github.com/containers/psgo.
func (c *Container) GetContainerPidInformation(descriptors []string) ([]string, error) {
pid := strconv.Itoa(c.state.PID)
- format := strings.Join(descriptors, ",")
- return ps.JoinNamespaceAndProcessInfo(pid, format)
+ // TODO: psgo returns a [][]string to give users the ability to apply
+ // filters on the data. We need to change the API here and the
+ // varlink API to return a [][]string if we want to make use of
+ // filtering.
+ psgoOutput, err := psgo.JoinNamespaceAndProcessInfo(pid, descriptors)
+ if err != nil {
+ return nil, err
+ }
+ res := []string{}
+ for _, out := range psgoOutput {
+ res = append(res, strings.Join(out, "\t"))
+ }
+ return res, nil
}
// GetContainerPidInformationDescriptors returns a string slice of all supported
// format descriptors of GetContainerPidInformation.
func GetContainerPidInformationDescriptors() ([]string, error) {
- return ps.ListDescriptors(), nil
+ return psgo.ListDescriptors(), nil
}