drivers: fix capabilities on non-linux systems (#24450)

Recently we moved from github.com/syndtr/gocapability to
github.com/moby/sys/capability due to the former package no longer being
maintainer. The new package's capability function works differently: the
known/supported functionality is split now, and the .ListSupported() call will
always return an empty list on non-linux systems. This means Nomad agents won't
start on darwin or windows.
This commit is contained in:
Piotr Kazmierczak
2024-11-13 15:58:25 +01:00
committed by GitHub
parent ff8ca8a4c5
commit 5dfb38d806

View File

@@ -6,6 +6,7 @@ package capabilities
import (
"fmt"
"regexp"
"runtime"
"github.com/moby/sys/capability"
)
@@ -40,7 +41,17 @@ func NomadDefaults() *Set {
func Supported() *Set {
s := New(nil)
list, _ := capability.ListSupported()
var list []capability.Cap
switch runtime.GOOS {
case "linux":
list, _ = capability.ListSupported()
default:
// capability.ListSupported() will always return an empty list on
// non-linux systems
list = capability.ListKnown()
}
// accumulate every capability supported by this system
for _, c := range list {
s.Add(c.String())