mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #17669 from WeixuZhuang/describ
Auto commit by PR queue bot
This commit is contained in:
commit
b5387da0d7
@ -1781,13 +1781,18 @@ type typeFunc struct {
|
||||
}
|
||||
|
||||
// Matches returns true when the passed types exactly match the Extra list.
|
||||
// TODO: allow unordered types to be matched and reorderd.
|
||||
func (fn typeFunc) Matches(types []reflect.Type) bool {
|
||||
if len(fn.Extra) != len(types) {
|
||||
return false
|
||||
}
|
||||
// reorder the items in array types and fn.Extra
|
||||
// convert the type into string and sort them, check if they are matched
|
||||
varMap := make(map[reflect.Type]bool)
|
||||
for i := range fn.Extra {
|
||||
varMap[fn.Extra[i]] = true
|
||||
}
|
||||
for i := range types {
|
||||
if fn.Extra[i] != types[i] {
|
||||
if _, found := varMap[types[i]]; !found {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user