From 23e890ea1bf08661ac99254b9644495ad7878cc3 Mon Sep 17 00:00:00 2001 From: mprahl Date: Mon, 10 Jun 2024 09:13:21 -0400 Subject: [PATCH] Make the watch namespace on OperatorPolicy conditional If OperatorPolicy is not enabled, the watch namespace shouldn't be set. It seems that setting the watch namespace causes the watch to start without the OperatorPolicy controller running. Signed-off-by: mprahl --- main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index cda8bd22..299ca492 100644 --- a/main.go +++ b/main.go @@ -228,10 +228,13 @@ func main() { "metadata.namespace": watchNamespace, }), } - cacheByObject[&policyv1beta1.OperatorPolicy{}] = cache.ByObject{ - Field: fields.SelectorFromSet(fields.Set{ - "metadata.namespace": watchNamespace, - }), + + if opts.enableOperatorPolicy { + cacheByObject[&policyv1beta1.OperatorPolicy{}] = cache.ByObject{ + Field: fields.SelectorFromSet(fields.Set{ + "metadata.namespace": watchNamespace, + }), + } } } else { log.Info("Skipping restrictions on the ConfigurationPolicy cache because watchNamespace is empty")