Webhooks#
Each resource has a generated webhook.go alongside its controller, in
internal/controllers/v1alpha1/<kind>/, with stubs for:
- Defaulting: Set default values on create/update
- Validation: Validate create, update, and delete operations
Whether a resource actually serves them is a per-resource switch in
.genop.yaml:
resources:
- version: v1alpha1
kind: Database
webhook:
validating: false
mutating: falseEdit the file, then run genop apply to update the packaging. A switch that stays enabled is absent from the file — only disabling is
ever written. genop apply turns those switches into packaging: a
disabled webhook is dropped from the ValidatingWebhookConfiguration /
MutatingWebhookConfiguration, and when no resource in the operator serves
a webhook at all, the webhook service, Issuer and Certificate are
removed too.
The Go code is generated unconditionally and reads the switches at
runtime, so flipping one never rewrites a .go file:
| Env var | Default |
|---|---|
<PLURAL>_VALIDATINGWEBHOOK_ENABLED | FALSE |
<PLURAL>_MUTATINGWEBHOOK_ENABLED | FALSE |
The generated controller-default-env ConfigMap sets both from the
topology, so the packaging is what decides. Each also has a matching flag
(--<plural>-validatingwebhook-enabled, …) for local runs.