build(deps): bump the golang group across 1 directory with 7 updates
Bumps the golang group with 6 updates in the / directory: | Package | From | To | | --- | --- | --- | | [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) | `0.12.7` | `0.12.9` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.20.2` | `2.22.0` | | [github.com/onsi/gomega](https://github.com/onsi/gomega) | `1.34.2` | `1.36.0` | | [github.com/opencontainers/selinux](https://github.com/opencontainers/selinux) | `1.11.0` | `1.11.1` | | [github.com/safchain/ethtool](https://github.com/safchain/ethtool) | `0.4.1` | `0.5.9` | | [sigs.k8s.io/knftables](https://github.com/kubernetes-sigs/knftables) | `0.0.17` | `0.0.18` | Updates `github.com/Microsoft/hcsshim` from 0.12.7 to 0.12.9 - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.12.7...v0.12.9) Updates `github.com/onsi/ginkgo/v2` from 2.20.2 to 2.22.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.20.2...v2.22.0) Updates `github.com/onsi/gomega` from 1.34.2 to 1.36.0 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.34.2...v1.36.0) Updates `github.com/opencontainers/selinux` from 1.11.0 to 1.11.1 - [Release notes](https://github.com/opencontainers/selinux/releases) - [Commits](https://github.com/opencontainers/selinux/compare/v1.11.0...v1.11.1) Updates `github.com/safchain/ethtool` from 0.4.1 to 0.5.9 - [Release notes](https://github.com/safchain/ethtool/releases) - [Commits](https://github.com/safchain/ethtool/compare/v0.4.1...v0.5.9) Updates `golang.org/x/sys` from 0.26.0 to 0.27.0 - [Commits](https://github.com/golang/sys/compare/v0.26.0...v0.27.0) Updates `sigs.k8s.io/knftables` from 0.0.17 to 0.0.18 - [Changelog](https://github.com/kubernetes-sigs/knftables/blob/master/CHANGELOG.md) - [Commits](https://github.com/kubernetes-sigs/knftables/compare/v0.0.17...v0.0.18) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-patch dependency-group: golang - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: github.com/opencontainers/selinux dependency-type: direct:production update-type: version-update:semver-patch dependency-group: golang - dependency-name: github.com/safchain/ethtool dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor dependency-group: golang - dependency-name: sigs.k8s.io/knftables dependency-type: direct:production update-type: version-update:semver-patch dependency-group: golang ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Casey Callendrello
parent
6de8a9853c
commit
3ffc42cdfd
95
vendor/sigs.k8s.io/knftables/fake.go
generated
vendored
95
vendor/sigs.k8s.io/knftables/fake.go
generated
vendored
@@ -23,20 +23,27 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Fake is a fake implementation of Interface
|
||||
type Fake struct {
|
||||
nftContext
|
||||
// mutex is used to protect Table and LastTransaction.
|
||||
// When Table and LastTransaction are accessed directly, the caller must acquire Fake.RLock
|
||||
// and release when finished.
|
||||
sync.RWMutex
|
||||
|
||||
nextHandle int
|
||||
|
||||
// Table contains the Interface's table. This will be `nil` until you `tx.Add()`
|
||||
// the table.
|
||||
// Make sure to acquire Fake.RLock before accessing Table in a concurrent environment.
|
||||
Table *FakeTable
|
||||
|
||||
// LastTransaction is the last transaction passed to Run(). It will remain set until the
|
||||
// next time Run() is called. (It is not affected by Check().)
|
||||
// Make sure to acquire Fake.RLock before accessing LastTransaction in a concurrent environment.
|
||||
LastTransaction *Transaction
|
||||
}
|
||||
|
||||
@@ -44,6 +51,9 @@ type Fake struct {
|
||||
type FakeTable struct {
|
||||
Table
|
||||
|
||||
// Flowtables contains the table's flowtables, keyed by name
|
||||
Flowtables map[string]*FakeFlowtable
|
||||
|
||||
// Chains contains the table's chains, keyed by name
|
||||
Chains map[string]*FakeChain
|
||||
|
||||
@@ -54,6 +64,11 @@ type FakeTable struct {
|
||||
Maps map[string]*FakeMap
|
||||
}
|
||||
|
||||
// FakeFlowtable wraps Flowtable for the Fake implementation
|
||||
type FakeFlowtable struct {
|
||||
Flowtable
|
||||
}
|
||||
|
||||
// FakeChain wraps Chain for the Fake implementation
|
||||
type FakeChain struct {
|
||||
Chain
|
||||
@@ -94,6 +109,8 @@ var _ Interface = &Fake{}
|
||||
|
||||
// List is part of Interface.
|
||||
func (fake *Fake) List(_ context.Context, objectType string) ([]string, error) {
|
||||
fake.RLock()
|
||||
defer fake.RUnlock()
|
||||
if fake.Table == nil {
|
||||
return nil, notFoundError("no such table %q", fake.table)
|
||||
}
|
||||
@@ -101,6 +118,10 @@ func (fake *Fake) List(_ context.Context, objectType string) ([]string, error) {
|
||||
var result []string
|
||||
|
||||
switch objectType {
|
||||
case "flowtable", "flowtables":
|
||||
for name := range fake.Table.Flowtables {
|
||||
result = append(result, name)
|
||||
}
|
||||
case "chain", "chains":
|
||||
for name := range fake.Table.Chains {
|
||||
result = append(result, name)
|
||||
@@ -123,6 +144,8 @@ func (fake *Fake) List(_ context.Context, objectType string) ([]string, error) {
|
||||
|
||||
// ListRules is part of Interface
|
||||
func (fake *Fake) ListRules(_ context.Context, chain string) ([]*Rule, error) {
|
||||
fake.RLock()
|
||||
defer fake.RUnlock()
|
||||
if fake.Table == nil {
|
||||
return nil, notFoundError("no such table %q", fake.table)
|
||||
}
|
||||
@@ -145,6 +168,8 @@ func (fake *Fake) ListRules(_ context.Context, chain string) ([]*Rule, error) {
|
||||
|
||||
// ListElements is part of Interface
|
||||
func (fake *Fake) ListElements(_ context.Context, objectType, name string) ([]*Element, error) {
|
||||
fake.RLock()
|
||||
defer fake.RUnlock()
|
||||
if fake.Table == nil {
|
||||
return nil, notFoundError("no such %s %q", objectType, name)
|
||||
}
|
||||
@@ -169,6 +194,8 @@ func (fake *Fake) NewTransaction() *Transaction {
|
||||
|
||||
// Run is part of Interface
|
||||
func (fake *Fake) Run(_ context.Context, tx *Transaction) error {
|
||||
fake.Lock()
|
||||
defer fake.Unlock()
|
||||
fake.LastTransaction = tx
|
||||
updatedTable, err := fake.run(tx)
|
||||
if err == nil {
|
||||
@@ -179,10 +206,13 @@ func (fake *Fake) Run(_ context.Context, tx *Transaction) error {
|
||||
|
||||
// Check is part of Interface
|
||||
func (fake *Fake) Check(_ context.Context, tx *Transaction) error {
|
||||
fake.RLock()
|
||||
defer fake.RUnlock()
|
||||
_, err := fake.run(tx)
|
||||
return err
|
||||
}
|
||||
|
||||
// must be called with fake.lock held
|
||||
func (fake *Fake) run(tx *Transaction) (*FakeTable, error) {
|
||||
if tx.err != nil {
|
||||
return nil, tx.err
|
||||
@@ -218,10 +248,11 @@ func (fake *Fake) run(tx *Transaction) (*FakeTable, error) {
|
||||
table := *obj
|
||||
table.Handle = PtrTo(fake.nextHandle)
|
||||
updatedTable = &FakeTable{
|
||||
Table: table,
|
||||
Chains: make(map[string]*FakeChain),
|
||||
Sets: make(map[string]*FakeSet),
|
||||
Maps: make(map[string]*FakeMap),
|
||||
Table: table,
|
||||
Flowtables: make(map[string]*FakeFlowtable),
|
||||
Chains: make(map[string]*FakeChain),
|
||||
Sets: make(map[string]*FakeSet),
|
||||
Maps: make(map[string]*FakeMap),
|
||||
}
|
||||
case deleteVerb:
|
||||
updatedTable = nil
|
||||
@@ -229,6 +260,29 @@ func (fake *Fake) run(tx *Transaction) (*FakeTable, error) {
|
||||
return nil, fmt.Errorf("unhandled operation %q", op.verb)
|
||||
}
|
||||
|
||||
case *Flowtable:
|
||||
existingFlowtable := updatedTable.Flowtables[obj.Name]
|
||||
err := checkExists(op.verb, "flowtable", obj.Name, existingFlowtable != nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch op.verb {
|
||||
case addVerb, createVerb:
|
||||
if existingFlowtable != nil {
|
||||
continue
|
||||
}
|
||||
flowtable := *obj
|
||||
flowtable.Handle = PtrTo(fake.nextHandle)
|
||||
updatedTable.Flowtables[obj.Name] = &FakeFlowtable{
|
||||
Flowtable: flowtable,
|
||||
}
|
||||
case deleteVerb:
|
||||
// FIXME delete-by-handle
|
||||
delete(updatedTable.Flowtables, obj.Name)
|
||||
default:
|
||||
return nil, fmt.Errorf("unhandled operation %q", op.verb)
|
||||
}
|
||||
|
||||
case *Chain:
|
||||
existingChain := updatedTable.Chains[obj.Name]
|
||||
err := checkExists(op.verb, "chain", obj.Name, existingChain != nil)
|
||||
@@ -443,10 +497,14 @@ func checkRuleRefs(rule *Rule, table *FakeTable) error {
|
||||
for i, word := range words {
|
||||
if strings.HasPrefix(word, "@") {
|
||||
name := word[1:]
|
||||
if i > 0 && (words[i] == "map" || words[i] == "vmap") {
|
||||
if i > 0 && (words[i-1] == "map" || words[i-1] == "vmap") {
|
||||
if table.Maps[name] == nil {
|
||||
return notFoundError("no such map %q", name)
|
||||
}
|
||||
} else if i > 0 && words[i-1] == "offload" {
|
||||
if table.Flowtables[name] == nil {
|
||||
return notFoundError("no such flowtable %q", name)
|
||||
}
|
||||
} else {
|
||||
// recent nft lets you use a map in a set lookup
|
||||
if table.Sets[name] == nil && table.Maps[name] == nil {
|
||||
@@ -480,6 +538,8 @@ func checkElementRefs(element *Element, table *FakeTable) error {
|
||||
|
||||
// Dump dumps the current contents of fake, in a way that looks like an nft transaction.
|
||||
func (fake *Fake) Dump() string {
|
||||
fake.RLock()
|
||||
defer fake.RUnlock()
|
||||
if fake.Table == nil {
|
||||
return ""
|
||||
}
|
||||
@@ -487,6 +547,7 @@ func (fake *Fake) Dump() string {
|
||||
buf := &strings.Builder{}
|
||||
|
||||
table := fake.Table
|
||||
flowtables := sortKeys(table.Flowtables)
|
||||
chains := sortKeys(table.Chains)
|
||||
sets := sortKeys(table.Sets)
|
||||
maps := sortKeys(table.Maps)
|
||||
@@ -494,6 +555,10 @@ func (fake *Fake) Dump() string {
|
||||
// Write out all of the object adds first.
|
||||
|
||||
table.writeOperation(addVerb, &fake.nftContext, buf)
|
||||
for _, fname := range flowtables {
|
||||
ft := table.Flowtables[fname]
|
||||
ft.writeOperation(addVerb, &fake.nftContext, buf)
|
||||
}
|
||||
for _, cname := range chains {
|
||||
ch := table.Chains[cname]
|
||||
ch.writeOperation(addVerb, &fake.nftContext, buf)
|
||||
@@ -550,7 +615,7 @@ func (fake *Fake) ParseDump(data string) (err error) {
|
||||
}
|
||||
}()
|
||||
tx := fake.NewTransaction()
|
||||
commonRegexp := regexp.MustCompile(fmt.Sprintf(`add %s %s %s (.*)`, noSpaceGroup, fake.family, fake.table))
|
||||
commonRegexp := regexp.MustCompile(fmt.Sprintf(`add ([^ ]*) %s %s( (.*))?`, fake.family, fake.table))
|
||||
|
||||
for i, line = range lines {
|
||||
line = strings.TrimSpace(line)
|
||||
@@ -565,6 +630,8 @@ func (fake *Fake) ParseDump(data string) (err error) {
|
||||
switch match[1] {
|
||||
case "table":
|
||||
obj = &Table{}
|
||||
case "flowtable":
|
||||
obj = &Flowtable{}
|
||||
case "chain":
|
||||
obj = &Chain{}
|
||||
case "rule":
|
||||
@@ -578,7 +645,7 @@ func (fake *Fake) ParseDump(data string) (err error) {
|
||||
default:
|
||||
return fmt.Errorf("unknown object %s", match[1])
|
||||
}
|
||||
err = obj.parse(match[2])
|
||||
err = obj.parse(match[3])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -623,10 +690,16 @@ func (table *FakeTable) copy() *FakeTable {
|
||||
}
|
||||
|
||||
tcopy := &FakeTable{
|
||||
Table: table.Table,
|
||||
Chains: make(map[string]*FakeChain),
|
||||
Sets: make(map[string]*FakeSet),
|
||||
Maps: make(map[string]*FakeMap),
|
||||
Table: table.Table,
|
||||
Flowtables: make(map[string]*FakeFlowtable),
|
||||
Chains: make(map[string]*FakeChain),
|
||||
Sets: make(map[string]*FakeSet),
|
||||
Maps: make(map[string]*FakeMap),
|
||||
}
|
||||
for name, flowtable := range table.Flowtables {
|
||||
tcopy.Flowtables[name] = &FakeFlowtable{
|
||||
Flowtable: flowtable.Flowtable,
|
||||
}
|
||||
}
|
||||
for name, chain := range table.Chains {
|
||||
tcopy.Chains[name] = &FakeChain{
|
||||
|
||||
Reference in New Issue
Block a user