I'm using the kubebuilder framework in my controller and I want to completely ignore events from a list of given system namespaces. I think predicates must be the best option for this, hence I have the following code
...
WithEventFilter(predicate.Funcs{
GenericFunc: func(e event.GenericEvent) bool {
namespace := e.Object.GetNamespace()
if _, ok := systemNs[namespace]; ok {
// ignore events from system namespaces
return false
}
return true
},
}).
However I still receive events from all namespaces instead of just the ones which I allow. Is this a correct and valid use case of predicates?
NewPredicateFuncs apply the filter on all events:
WithEventFilter(predicate.NewPredicateFuncs(func(obj client.Object) bool {
_, ok := systemNs[obj.GetNamespace()]
return !ok
})).