summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-30 21:29:26 +0200
committerGitHub <noreply@github.com>2021-03-30 21:29:26 +0200
commitbd07179e9c608ff1075f052843aeb9b1c8b7c7e3 (patch)
treec99b7a41571e0b7593afe0a197747685e4670b66 /pkg/api
parent989c8e97851c1a443270e803e19dd069fc199302 (diff)
parenteef66973de4738536810be71b91e3503e7aa5183 (diff)
downloadpodman-bd07179e9c608ff1075f052843aeb9b1c8b7c7e3.tar.gz
podman-bd07179e9c608ff1075f052843aeb9b1c8b7c7e3.tar.bz2
podman-bd07179e9c608ff1075f052843aeb9b1c8b7c7e3.zip
Merge pull request #9892 from jwhonce/wip/top
Trim white space from /top endpoint results
Diffstat (limited to 'pkg/api')
-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)