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: false

Edit 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 varDefault
<PLURAL>_VALIDATINGWEBHOOK_ENABLEDFALSE
<PLURAL>_MUTATINGWEBHOOK_ENABLEDFALSE

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.