Skip to content

Commit 342abf7

Browse files
committed
fix: initialize default namespace when given
Otherwise the controller is not able to delete the vcluster.
1 parent ea53d5c commit 342abf7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ func main() {
7575

7676
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
7777

78+
var namespaces map[string]cache.Config
79+
if namespace != "" {
80+
namespaces = map[string]cache.Config{
81+
namespace: {},
82+
}
83+
}
84+
7885
mgr, err := manager.New(ctrl.GetConfigOrDie(), manager.Options{
7986
Scheme: scheme,
8087
Metrics: metricsserver.Options{
@@ -87,9 +94,7 @@ func main() {
8794
LeaderElection: enableLeaderElection,
8895
LeaderElectionID: "4012c7fa.cluster.x-k8s.io",
8996
Cache: cache.Options{
90-
DefaultNamespaces: map[string]cache.Config{
91-
namespace: {},
92-
},
97+
DefaultNamespaces: namespaces,
9398
},
9499
})
95100
if err != nil {

0 commit comments

Comments
 (0)