caps.go 649 B

123456789101112131415161718192021222324
  1. // Package capabilities allows to generically handle capabilities.
  2. package capabilities // import "github.com/docker/docker/pkg/capabilities"
  3. // Set represents a set of capabilities.
  4. type Set map[string]struct{}
  5. // Match tries to match set with caps, which is an OR list of AND lists of capabilities.
  6. // The matched AND list of capabilities is returned; or nil if none are matched.
  7. func (set Set) Match(caps [][]string) []string {
  8. if set == nil {
  9. return nil
  10. }
  11. anyof:
  12. for _, andList := range caps {
  13. for _, cap := range andList {
  14. if _, ok := set[cap]; !ok {
  15. continue anyof
  16. }
  17. }
  18. return andList
  19. }
  20. // match anything
  21. return nil
  22. }