refactor: optimizing watchers predicates

This commit is contained in:
Dario Tranchitella
2022-05-05 13:33:39 +00:00
parent 345836630c
commit 01197892a4
5 changed files with 34 additions and 79 deletions
+19
View File
@@ -0,0 +1,19 @@
package utils
import (
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)
func NamesMatchingPredicate(names ...string) builder.Predicates {
return builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
for _, name := range names {
if object.GetName() == name {
return true
}
}
return false
}))
}