From f995a3b025fdd5c5acf2cfec6efaddf75cac7cec Mon Sep 17 00:00:00 2001 From: Saman Mahdanian Date: Wed, 12 Jun 2024 18:20:00 +0330 Subject: [PATCH] fix nil issue in Join function --- controllers/namespace_controller.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controllers/namespace_controller.go b/controllers/namespace_controller.go index e2273b0..a3dba9b 100644 --- a/controllers/namespace_controller.go +++ b/controllers/namespace_controller.go @@ -67,6 +67,12 @@ type SafeNsCache struct { func (c *SafeNsCache) JoinProject(ns, proj string) { c.mu.Lock() defer c.mu.Unlock() + if _, ok := c.projects[ns]; !ok { + c.projects[ns] = make(AppProjectNameset) + } + if _, ok := c.namespaces[proj]; !ok { + c.namespaces[proj] = make(NamespaceNameset) + } c.projects[ns][proj] = struct{}{} c.namespaces[proj][ns] = struct{}{} }