summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-08-01 14:12:32 -0400
committerPeter Hunt <pehunt@redhat.com>2019-08-01 14:12:36 -0400
commit3acfcb30628ed937200a144817f52ee52cfc2e40 (patch)
treeaf6dac7b1df62aa2e6f95fc7bb44cc3d4b0c7c65 /libpod
parentafb493ae9b1cc98db1f6d9a211b561bb245692de (diff)
downloadpodman-3acfcb30628ed937200a144817f52ee52cfc2e40.tar.gz
podman-3acfcb30628ed937200a144817f52ee52cfc2e40.tar.bz2
podman-3acfcb30628ed937200a144817f52ee52cfc2e40.zip
Deduplicate capabilities in generate kube
capabilities that were added and dropped were several times duplicated. Fix this Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/kube.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/libpod/kube.go b/libpod/kube.go
index 084a3df4f..d46a82856 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -406,18 +406,26 @@ func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v
drop []v1.Capability
add []v1.Capability
)
+ dedupDrop := make(map[string]bool)
+ dedupAdd := make(map[string]bool)
// Find caps in the defaultCaps but not in the container's
// those indicate a dropped cap
for _, capability := range defaultCaps {
if !util.StringInSlice(capability, containerCaps) {
- drop = append(drop, v1.Capability(capability))
+ if _, ok := dedupDrop[capability]; !ok {
+ drop = append(drop, v1.Capability(capability))
+ dedupDrop[capability] = true
+ }
}
}
// Find caps in the container but not in the defaults; those indicate
// an added cap
for _, capability := range containerCaps {
if !util.StringInSlice(capability, defaultCaps) {
- add = append(add, v1.Capability(capability))
+ if _, ok := dedupAdd[string(capability)]; !ok {
+ add = append(add, v1.Capability(capability))
+ dedupAdd[capability] = true
+ }
}
}