mirror of
https://github.com/rancher/plugins.git
synced 2025-09-25 19:32:05 +00:00
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
241
vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go
generated
vendored
241
vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
"github.com/onsi/gomega/matchers/internal/miter"
|
||||
)
|
||||
|
||||
type ContainElementMatcher struct {
|
||||
@@ -16,16 +17,18 @@ type ContainElementMatcher struct {
|
||||
}
|
||||
|
||||
func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
if !isArrayOrSlice(actual) && !isMap(actual) {
|
||||
return false, fmt.Errorf("ContainElement matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1))
|
||||
if !isArrayOrSlice(actual) && !isMap(actual) && !miter.IsIter(actual) {
|
||||
return false, fmt.Errorf("ContainElement matcher expects an array/slice/map/iterator. Got:\n%s", format.Object(actual, 1))
|
||||
}
|
||||
|
||||
var actualT reflect.Type
|
||||
var result reflect.Value
|
||||
switch l := len(matcher.Result); {
|
||||
case l > 1:
|
||||
switch numResultArgs := len(matcher.Result); {
|
||||
case numResultArgs > 1:
|
||||
return false, errors.New("ContainElement matcher expects at most a single optional pointer to store its findings at")
|
||||
case l == 1:
|
||||
case numResultArgs == 1:
|
||||
// Check the optional result arg to point to a single value/array/slice/map
|
||||
// of a type compatible with the actual value.
|
||||
if reflect.ValueOf(matcher.Result[0]).Kind() != reflect.Ptr {
|
||||
return false, fmt.Errorf("ContainElement matcher expects a non-nil pointer to store its findings at. Got\n%s",
|
||||
format.Object(matcher.Result[0], 1))
|
||||
@@ -34,93 +37,209 @@ func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, e
|
||||
resultReference := matcher.Result[0]
|
||||
result = reflect.ValueOf(resultReference).Elem() // what ResultReference points to, to stash away our findings
|
||||
switch result.Kind() {
|
||||
case reflect.Array:
|
||||
case reflect.Array: // result arrays are not supported, as they cannot be dynamically sized.
|
||||
if miter.IsIter(actual) {
|
||||
_, actualvT := miter.IterKVTypes(actual)
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
reflect.SliceOf(actualvT), result.Type().String())
|
||||
}
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
reflect.SliceOf(actualT.Elem()).String(), result.Type().String())
|
||||
case reflect.Slice:
|
||||
if !isArrayOrSlice(actual) {
|
||||
|
||||
case reflect.Slice: // result slice
|
||||
// can we assign elements in actual to elements in what the result
|
||||
// arg points to?
|
||||
// - ✔ actual is an array or slice
|
||||
// - ✔ actual is an iter.Seq producing "v" elements
|
||||
// - ✔ actual is an iter.Seq2 producing "v" elements, ignoring
|
||||
// the "k" elements.
|
||||
switch {
|
||||
case isArrayOrSlice(actual):
|
||||
if !actualT.Elem().AssignableTo(result.Type().Elem()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.String(), result.Type().String())
|
||||
}
|
||||
|
||||
case miter.IsIter(actual):
|
||||
_, actualvT := miter.IterKVTypes(actual)
|
||||
if !actualvT.AssignableTo(result.Type().Elem()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualvT.String(), result.Type().String())
|
||||
}
|
||||
|
||||
default: // incompatible result reference
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
reflect.MapOf(actualT.Key(), actualT.Elem()).String(), result.Type().String())
|
||||
}
|
||||
if !actualT.Elem().AssignableTo(result.Type().Elem()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.String(), result.Type().String())
|
||||
}
|
||||
case reflect.Map:
|
||||
if !isMap(actual) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.String(), result.Type().String())
|
||||
}
|
||||
if !actualT.AssignableTo(result.Type()) {
|
||||
|
||||
case reflect.Map: // result map
|
||||
// can we assign elements in actual to elements in what the result
|
||||
// arg points to?
|
||||
// - ✔ actual is a map
|
||||
// - ✔ actual is an iter.Seq2 (iter.Seq doesn't fit though)
|
||||
switch {
|
||||
case isMap(actual):
|
||||
if !actualT.AssignableTo(result.Type()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.String(), result.Type().String())
|
||||
}
|
||||
|
||||
case miter.IsIter(actual):
|
||||
actualkT, actualvT := miter.IterKVTypes(actual)
|
||||
if actualkT == nil {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
reflect.SliceOf(actualvT).String(), result.Type().String())
|
||||
}
|
||||
if !reflect.MapOf(actualkT, actualvT).AssignableTo(result.Type()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
reflect.MapOf(actualkT, actualvT), result.Type().String())
|
||||
}
|
||||
|
||||
default: // incompatible result reference
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.String(), result.Type().String())
|
||||
}
|
||||
|
||||
default:
|
||||
if !actualT.Elem().AssignableTo(result.Type()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.Elem().String(), result.Type().String())
|
||||
// can we assign a (single) element in actual to what the result arg
|
||||
// points to?
|
||||
switch {
|
||||
case miter.IsIter(actual):
|
||||
_, actualvT := miter.IterKVTypes(actual)
|
||||
if !actualvT.AssignableTo(result.Type()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualvT.String(), result.Type().String())
|
||||
}
|
||||
default:
|
||||
if !actualT.Elem().AssignableTo(result.Type()) {
|
||||
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
|
||||
actualT.Elem().String(), result.Type().String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the supplied matcher isn't an Omega matcher, default to the Equal
|
||||
// matcher.
|
||||
elemMatcher, elementIsMatcher := matcher.Element.(omegaMatcher)
|
||||
if !elementIsMatcher {
|
||||
elemMatcher = &EqualMatcher{Expected: matcher.Element}
|
||||
}
|
||||
|
||||
value := reflect.ValueOf(actual)
|
||||
var valueAt func(int) interface{}
|
||||
|
||||
var getFindings func() reflect.Value
|
||||
var foundAt func(int)
|
||||
var getFindings func() reflect.Value // abstracts how the findings are collected and stored
|
||||
var lastError error
|
||||
|
||||
if isMap(actual) {
|
||||
keys := value.MapKeys()
|
||||
valueAt = func(i int) interface{} {
|
||||
return value.MapIndex(keys[i]).Interface()
|
||||
}
|
||||
if result.Kind() != reflect.Invalid {
|
||||
fm := reflect.MakeMap(actualT)
|
||||
getFindings = func() reflect.Value {
|
||||
return fm
|
||||
if !miter.IsIter(actual) {
|
||||
var valueAt func(int) interface{}
|
||||
var foundAt func(int)
|
||||
// We're dealing with an array/slice/map, so in all cases we can iterate
|
||||
// over the elements in actual using indices (that can be considered
|
||||
// keys in case of maps).
|
||||
if isMap(actual) {
|
||||
keys := value.MapKeys()
|
||||
valueAt = func(i int) interface{} {
|
||||
return value.MapIndex(keys[i]).Interface()
|
||||
}
|
||||
foundAt = func(i int) {
|
||||
fm.SetMapIndex(keys[i], value.MapIndex(keys[i]))
|
||||
if result.Kind() != reflect.Invalid {
|
||||
fm := reflect.MakeMap(actualT)
|
||||
getFindings = func() reflect.Value { return fm }
|
||||
foundAt = func(i int) {
|
||||
fm.SetMapIndex(keys[i], value.MapIndex(keys[i]))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
valueAt = func(i int) interface{} {
|
||||
return value.Index(i).Interface()
|
||||
}
|
||||
if result.Kind() != reflect.Invalid {
|
||||
var fsl reflect.Value
|
||||
if result.Kind() == reflect.Slice {
|
||||
fsl = reflect.MakeSlice(result.Type(), 0, 0)
|
||||
} else {
|
||||
fsl = reflect.MakeSlice(reflect.SliceOf(result.Type()), 0, 0)
|
||||
}
|
||||
getFindings = func() reflect.Value { return fsl }
|
||||
foundAt = func(i int) {
|
||||
fsl = reflect.Append(fsl, value.Index(i))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
elem := valueAt(i)
|
||||
success, err := elemMatcher.Match(elem)
|
||||
if err != nil {
|
||||
lastError = err
|
||||
continue
|
||||
}
|
||||
if success {
|
||||
if result.Kind() == reflect.Invalid {
|
||||
return true, nil
|
||||
}
|
||||
foundAt(i)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
valueAt = func(i int) interface{} {
|
||||
return value.Index(i).Interface()
|
||||
}
|
||||
// We're dealing with an iterator as a first-class construct, so things
|
||||
// are slightly different: there is no index defined as in case of
|
||||
// arrays/slices/maps, just "ooooorder"
|
||||
var found func(k, v reflect.Value)
|
||||
if result.Kind() != reflect.Invalid {
|
||||
var f reflect.Value
|
||||
if result.Kind() == reflect.Slice {
|
||||
f = reflect.MakeSlice(result.Type(), 0, 0)
|
||||
if result.Kind() == reflect.Map {
|
||||
fm := reflect.MakeMap(result.Type())
|
||||
getFindings = func() reflect.Value { return fm }
|
||||
found = func(k, v reflect.Value) { fm.SetMapIndex(k, v) }
|
||||
} else {
|
||||
f = reflect.MakeSlice(reflect.SliceOf(result.Type()), 0, 0)
|
||||
}
|
||||
getFindings = func() reflect.Value {
|
||||
return f
|
||||
}
|
||||
foundAt = func(i int) {
|
||||
f = reflect.Append(f, value.Index(i))
|
||||
var fsl reflect.Value
|
||||
if result.Kind() == reflect.Slice {
|
||||
fsl = reflect.MakeSlice(result.Type(), 0, 0)
|
||||
} else {
|
||||
fsl = reflect.MakeSlice(reflect.SliceOf(result.Type()), 0, 0)
|
||||
}
|
||||
getFindings = func() reflect.Value { return fsl }
|
||||
found = func(_, v reflect.Value) { fsl = reflect.Append(fsl, v) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var lastError error
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
elem := valueAt(i)
|
||||
success, err := elemMatcher.Match(elem)
|
||||
if err != nil {
|
||||
lastError = err
|
||||
continue
|
||||
success := false
|
||||
actualkT, _ := miter.IterKVTypes(actual)
|
||||
if actualkT == nil {
|
||||
miter.IterateV(actual, func(v reflect.Value) bool {
|
||||
var err error
|
||||
success, err = elemMatcher.Match(v.Interface())
|
||||
if err != nil {
|
||||
lastError = err
|
||||
return true // iterate on...
|
||||
}
|
||||
if success {
|
||||
if result.Kind() == reflect.Invalid {
|
||||
return false // a match and no result needed, so we're done
|
||||
}
|
||||
found(reflect.Value{}, v)
|
||||
}
|
||||
return true // iterate on...
|
||||
})
|
||||
} else {
|
||||
miter.IterateKV(actual, func(k, v reflect.Value) bool {
|
||||
var err error
|
||||
success, err = elemMatcher.Match(v.Interface())
|
||||
if err != nil {
|
||||
lastError = err
|
||||
return true // iterate on...
|
||||
}
|
||||
if success {
|
||||
if result.Kind() == reflect.Invalid {
|
||||
return false // a match and no result needed, so we're done
|
||||
}
|
||||
found(k, v)
|
||||
}
|
||||
return true // iterate on...
|
||||
})
|
||||
}
|
||||
if success {
|
||||
if result.Kind() == reflect.Invalid {
|
||||
return true, nil
|
||||
}
|
||||
foundAt(i)
|
||||
if success && result.Kind() == reflect.Invalid {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user