Commit Graph

2 Commits

Author SHA1 Message Date
Gabriele Quaresima
176b55de78 chore: add unit tests, improve log and code readability
- Add 'namespace' structured field to the error log in Reconcile when
  a role reconciliation fails
- Rename misleading local variable 'role' to 'roleBinding' in
  ensureRoleBinding to match the actual type
- Add EnsureRole tests: transient Role creation error is propagated;
  pre-existing unrelated labels are preserved after patch
- Add SetControllerReference test: returns an error when the owner
  does not implement runtime.Object
- Add ObjectStoreReconciler tests: Role list failure and ObjectStore
  Get transient error both surface through the reconcile return value
- Add scheme tests: AddCNPGToScheme with default and custom group/version

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
2026-04-10 16:59:34 +02:00
Marco Nenciarini
0475daa589
fix: read owner GVK from object metadata instead of scheme
The operator does not know the CNPG API group at runtime (it is
not a sidecar injected by the CNPG operator, so CUSTOM_CNPG_GROUP
and CUSTOM_CNPG_VERSION are not available). Move SetControllerReference
to the specs package and read the GVK from the decoded Cluster's
TypeMeta rather than looking it up in the scheme.

Remove CNPG types from the operator's scheme and the env var bindings
from cmd/operator since they are no longer needed.

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
2026-04-10 11:23:35 +02:00