server: abstract out linux capability per platform
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
d6966951d6
commit
4d88008a65
3 changed files with 24 additions and 4 deletions
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/kubernetes-incubator/cri-o/lib/sandbox"
|
"github.com/kubernetes-incubator/cri-o/lib/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/server/metrics"
|
"github.com/kubernetes-incubator/cri-o/server/metrics"
|
||||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/opencontainers/runtime-tools/validate"
|
|
||||||
"github.com/syndtr/gocapability/capability"
|
"github.com/syndtr/gocapability/capability"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
||||||
)
|
)
|
||||||
|
@ -179,11 +178,11 @@ func inStringSlice(ss []string, str string) bool {
|
||||||
// getOCICapabilitiesList returns a list of all available capabilities.
|
// getOCICapabilitiesList returns a list of all available capabilities.
|
||||||
func getOCICapabilitiesList() []string {
|
func getOCICapabilitiesList() []string {
|
||||||
var caps []string
|
var caps []string
|
||||||
for _, cap := range capability.List() {
|
for _, c := range capability.List() {
|
||||||
if cap > validate.LastCap() {
|
if c > lastCapability() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
caps = append(caps, "CAP_"+strings.ToUpper(cap.String()))
|
caps = append(caps, "CAP_"+strings.ToUpper(c.String()))
|
||||||
}
|
}
|
||||||
return caps
|
return caps
|
||||||
}
|
}
|
||||||
|
|
12
server/utils_linux.go
Normal file
12
server/utils_linux.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// +build linux
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/opencontainers/runtime-tools/validate"
|
||||||
|
"github.com/syndtr/gocapability/capability"
|
||||||
|
)
|
||||||
|
|
||||||
|
func lastCapability() capability.Cap {
|
||||||
|
return validate.LastCap()
|
||||||
|
}
|
9
server/utils_unsupported.go
Normal file
9
server/utils_unsupported.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// +build !linux
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import "github.com/syndtr/gocapability/capability"
|
||||||
|
|
||||||
|
func lastCapability() capability.Cap {
|
||||||
|
return capability.Cap(-1)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue