Files
moby/daemon/internal/capabilities/caps.go
Sebastiaan van Stijn d80a3f2e48 pkg/capabilities move to daemon/internal
This package was added in 8f936ae8cf, and
never had external consumers. Let's move it internal.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 00:49:15 +02:00

25 lines
595 B
Go

// Package capabilities allows to generically handle capabilities.
package capabilities
// Set represents a set of capabilities.
type Set map[string]struct{}
// Match tries to match set with caps, which is an OR list of AND lists of capabilities.
// The matched AND list of capabilities is returned; or nil if none are matched.
func (set Set) Match(caps [][]string) []string {
if set == nil {
return nil
}
anyof:
for _, andList := range caps {
for _, cap := range andList {
if _, ok := set[cap]; !ok {
continue anyof
}
}
return andList
}
// match anything
return nil
}