summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-03-30 10:42:06 -0700
committerJhon Honce <jhonce@redhat.com>2021-03-30 10:42:06 -0700
commiteef66973de4738536810be71b91e3503e7aa5183 (patch)
tree4d71adeee14ebb4a2f41120e2333f771d5d82c8d /pkg
parentf7ad9fbd9e334b5daf9f3af9160cc8fab82255d6 (diff)
downloadpodman-eef66973de4738536810be71b91e3503e7aa5183.tar.gz
podman-eef66973de4738536810be71b91e3503e7aa5183.tar.bz2
podman-eef66973de4738536810be71b91e3503e7aa5183.zip
Trim white space from /top endpoint results
Versions of the ps command have additional spaces between fields, this manifests as the container asking to run "top" and API reporting "top " as a process. Endpoint and tests updated to check that "top" is reported. There is no libpod specialized endpoint to update. Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/containers_top.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/containers_top.go b/pkg/api/handlers/compat/containers_top.go
index ab9f613af..cae044a89 100644
--- a/pkg/api/handlers/compat/containers_top.go
+++ b/pkg/api/handlers/compat/containers_top.go
@@ -46,8 +46,16 @@ func TopContainer(w http.ResponseWriter, r *http.Request) {
var body = handlers.ContainerTopOKBody{}
if len(output) > 0 {
body.Titles = strings.Split(output[0], "\t")
+ for i := range body.Titles {
+ body.Titles[i] = strings.TrimSpace(body.Titles[i])
+ }
+
for _, line := range output[1:] {
- body.Processes = append(body.Processes, strings.Split(line, "\t"))
+ process := strings.Split(line, "\t")
+ for i := range process {
+ process[i] = strings.TrimSpace(process[i])
+ }
+ body.Processes = append(body.Processes, process)
}
}
utils.WriteJSON(w, http.StatusOK, body)