This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Filter by arbitrary callback function #98
Labels
enhancement
New feature or request
Comments
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 (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/zalando-incubator/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 @Jc2k Thank you very much for your contribution! |
5 tasks
5 tasks
8 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
The text was updated successfully, but these errors were encountered: