Go core engine, built on controller-runtime / Kubebuilder. One reconciler package per
custom resource: terraformlayer/, terraformrun/, terraformrepository/,
terraformpullrequest/. metrics/ holds Prometheus instrumentation. manager.go wires them.
- Follow standard
controller-runtimereconciliation patterns and the Kubebuilder layout. - Reconcilers must be idempotent — they can run on the same object repeatedly.
- Never block the reconcile loop. For retries/transient failures, return a requeue
(
ctrl.Result{RequeueAfter: ...}), do not sleep. - Never
panic(). Return an error or a requeue. - Always check errors explicitly — no
_ = err. - Use structured logging via the
logr.Loggercarried inctx(log.FromContext(ctx)). - Propagate
ctxand set timeouts on every external call (GitHub, GitLab, Terraform). - CRD shapes live in
api/v1alpha1; never edit generated deepcopy code. After API changes runmake manifests && make generate. - State machines are documented. When you change a reconciler's states or transitions (its
states.go— theGetStateswitch, state structs, or the conditions inconditions.gothat drive them), update the matching Mermaid diagram indocs/operator-manual/state-machines.mdso it stays in sync.