From 85ab385439db1e29c98800fcaaf56d530adf0989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Andr=C3=A9s=20Villar?= Date: Thu, 16 Oct 2025 10:20:26 +0200 Subject: [PATCH] Feat: improve CEL expression checks in mutating webhook configuration --- internal/controller/overcommitclass/utils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/controller/overcommitclass/utils.go b/internal/controller/overcommitclass/utils.go index 690a045..3e268ae 100644 --- a/internal/controller/overcommitclass/utils.go +++ b/internal/controller/overcommitclass/utils.go @@ -224,6 +224,22 @@ func webhookChanged(updated, current interface{}) bool { } } + // Compare MatchConditions (including CEL expressions for namespace exclusion) + if len(updatedWebhook.MatchConditions) != len(currentWebhook.MatchConditions) { + return true + } + + for i, updatedCondition := range updatedWebhook.MatchConditions { + if i >= len(currentWebhook.MatchConditions) { + return true + } + currentCondition := currentWebhook.MatchConditions[i] + if updatedCondition.Name != currentCondition.Name || + updatedCondition.Expression != currentCondition.Expression { + return true + } + } + // If we reach here, they're likely the same return false }