You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases, it might be needed that only a subset of resources is served and handled. Some of such filtering are suggested in #45#58, but it can be anything arbitrary.
Without such filtering, the logs will be cluttered by the resource events/causes that are of no interest to the operator.
For this, a callback function can be specified on the handler declaration:
The callback should be called via the same invocation protocol as the handlers (see kopf.reactor.invocation), i.e. with all the handler's kwargs — be that an event-handler or a cause-handler (different sets of kwargs).
If the callback returns true, then the object is handled as normally. When it returns false, the handler is ignored, maybe the whole event is ignored (if there are no other handlers) — and therefore produces no single line of logs at all.
No additional kwargs are injected for such filtering.
In some cases, it might be needed that only a subset of resources is served and handled. Some of such filtering are suggested in #45 #58, but it can be anything arbitrary.
Without such filtering, the logs will be cluttered by the resource events/causes that are of no interest to the operator.
For this, a callback function can be specified on the handler declaration:
The callback should be called via the same invocation protocol as the handlers (see
kopf.reactor.invocation
), i.e. with all the handler's kwargs — be that an event-handler or a cause-handler (different sets of kwargs).If the callback returns true, then the object is handled as normally. When it returns false, the handler is ignored, maybe the whole event is ignored (if there are no other handlers) — and therefore produces no single line of logs at all.
No additional kwargs are injected for such filtering.
Related:
Checklist:
This would be really handy for me.
I was thinking about writing a cert-manager plugin with kopf - something like this.
With this feature I would be able to filter out
CertificateRequests
that weren't "assigned" to my operator by looking atspec.issuerRef
.(Presumably these objects would then not be tagged with the kopf last-configuration annotations etc too).
I think, it is easily implementable now. Since at least some filters were added in #123 (by labels/annotations), adding more filters is easy.
A starting place to look for: https://github.com/nolar/kopf/blob/0.23.2/kopf/reactor/registries.py#L570-L623
Thanks for the hint. I've had a bash at this in #258.
Released as
kopf==0.25
.Jc2k Thank you very much for your contribution!
The text was updated successfully, but these errors were encountered: