From 5888b4923c515131429de9766e3a1d3ba33114ec Mon Sep 17 00:00:00 2001 From: Johannes Frey Date: Thu, 13 Jun 2024 11:08:30 +0200 Subject: [PATCH] fix: initialize default namespace when given Otherwise the controller is not able to delete the vcluster. --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5fc621a5..4b2f9d91 100644 --- a/main.go +++ b/main.go @@ -75,6 +75,13 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) + var namespaces map[string]cache.Config + if namespace != "" { + namespaces = map[string]cache.Config{ + namespace: {}, + } + } + mgr, err := manager.New(ctrl.GetConfigOrDie(), manager.Options{ Scheme: scheme, Metrics: metricsserver.Options{ @@ -87,9 +94,7 @@ func main() { LeaderElection: enableLeaderElection, LeaderElectionID: "4012c7fa.cluster.x-k8s.io", Cache: cache.Options{ - DefaultNamespaces: map[string]cache.Config{ - namespace: {}, - }, + DefaultNamespaces: namespaces, }, }) if err != nil {