Skip to content

Commit

Permalink
[test] Switch to github.com/moby/sys/capability
Browse files Browse the repository at this point in the history
This is a fork of the (no longer maintained)
github.com/syndtr/gocapability package.

For changes since the fork took place, see
https://github.com/moby/sys/blob/main/capability/CHANGELOG.md

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Sep 25, 2024
1 parent 36e5f50 commit 82cf171
Show file tree
Hide file tree
Showing 15 changed files with 1,461 additions and 15 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/jinzhu/copier v0.4.0
github.com/json-iterator/go v1.1.12
github.com/moby/sys/capability v0.2.1-0.20240925213336-aaea55a66478
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/opencontainers/go-digest v1.0.0
Expand All @@ -41,7 +42,6 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/vishvananda/netlink v1.3.0
go.etcd.io/bbolt v1.3.11
golang.org/x/crypto v0.27.0
Expand Down Expand Up @@ -124,6 +124,7 @@ require (
github.com/sigstore/sigstore v1.8.4 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 // indirect
github.com/sylabs/sif/v2 v2.18.0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/sys/capability v0.2.1-0.20240925213336-aaea55a66478 h1:L1of2hA2QHy7I07JaRddpvaDL6D72xYzRLkJp8OibzA=
github.com/moby/sys/capability v0.2.1-0.20240925213336-aaea55a66478/go.mod h1:4g9IK291rVkms3LKCDOoYlnV8xKwoDTpIrNEE35Wq0I=
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
github.com/moby/sys/mountinfo v0.7.2/go.mod h1:1YOa8w8Ih7uW0wALDUgT1dTTSBrZ+HiBLGws92L2RU4=
github.com/moby/sys/user v0.3.0 h1:9ni5DlcW5an3SvRSx4MouotOygvzaXbaSrc/wGDFWPo=
Expand Down
17 changes: 3 additions & 14 deletions pkg/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"sync"

"github.com/syndtr/gocapability/capability"
"github.com/moby/sys/capability"
)

var (
Expand All @@ -32,21 +32,10 @@ func capName(c capability.Cap) string {
return "CAP_" + strings.ToUpper(c.String())
}

// capList returns all capabilities supported by the currently running kernel,
// or an error if the list can not be obtained.
var capList = sync.OnceValues(func() ([]capability.Cap, error) {
last := capability.CAP_LAST_CAP
list := capability.List() // All known caps.
return slices.DeleteFunc(list, func(c capability.Cap) bool {
// Remove caps not supported by the kernel.
return c > last
}), nil
})

// capStrList returns all capabilities supported by the currently running kernel,
// or an error if the list can not be obtained.
var capStrList = sync.OnceValues(func() ([]string, error) {
list, err := capList()
list, err := capability.ListSupported()
if err != nil {
return nil, err
}
Expand All @@ -72,7 +61,7 @@ var boundingSet = sync.OnceValues(func() ([]string, error) {
if err != nil {
return nil, err
}
list, err := capList()
list, err := capability.ListSupported()
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions vendor/github.com/moby/sys/capability/.codespellrc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/moby/sys/capability/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions vendor/github.com/moby/sys/capability/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions vendor/github.com/moby/sys/capability/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/moby/sys/capability/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions vendor/github.com/moby/sys/capability/capability.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 82cf171

Please sign in to comment.