summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Sakař <petr.sakar@chare.eu>2020-11-20 17:48:16 +0100
committerPetr Sakař <petr.sakar@chare.eu>2020-11-20 21:46:51 +0100
commit435f61f497beb19816c8dc800309081ccef2cda9 (patch)
treeecac26f3e8dc372ec76090a4a156819e4f810884
parenta18365c908d45a8ee9348c5e32a240a7b9a4091b (diff)
downloadpodman-435f61f497beb19816c8dc800309081ccef2cda9.tar.gz
podman-435f61f497beb19816c8dc800309081ccef2cda9.tar.bz2
podman-435f61f497beb19816c8dc800309081ccef2cda9.zip
APIv2 - strip CAP_ prefix from capabilities in json
strip prefix "CAP_" from capabilities in json generated by container inspect operation Signed-off-by: Petr Sakař <petr.sakar@chare.eu>
-rw-r--r--pkg/api/handlers/compat/containers.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 00be8e845..0ee96b855 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -298,6 +298,9 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
state.Running = true
}
+ formatCapabilities(inspect.HostConfig.CapDrop)
+ formatCapabilities(inspect.HostConfig.CapAdd)
+
h, err := json.Marshal(inspect.HostConfig)
if err != nil {
return nil, err
@@ -428,3 +431,9 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
}
return &c, nil
}
+
+func formatCapabilities(slice []string) {
+ for i := range slice {
+ slice[i] = strings.TrimPrefix(slice[i], "CAP_")
+ }
+}