From 01db666d4479974c2dfd259e123ac1dfe11b70ab Mon Sep 17 00:00:00 2001 From: Mateusz Kubaczyk Date: Tue, 24 Nov 2020 10:45:10 +0100 Subject: [PATCH 1/2] Initialize namespaces defined without any properties on init --- internal/app/cli.go | 1 + internal/app/state.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/internal/app/cli.go b/internal/app/cli.go index ed355508..b58a12c6 100644 --- a/internal/app/cli.go +++ b/internal/app/cli.go @@ -245,6 +245,7 @@ func (c *cli) readState(s *state) { } s.setDefaults() + s.initializeNamespaces() s.disableUntargetedApps(c.group, c.target) if len(c.target) > 0 && len(s.TargetMap) == 0 { diff --git a/internal/app/state.go b/internal/app/state.go index b41dc349..b13cc232 100644 --- a/internal/app/state.go +++ b/internal/app/state.go @@ -68,6 +68,15 @@ func (s *state) setDefaults() { } } +func (s *state) initializeNamespaces() { + for nsName, ns := range s.Namespaces { + if ns == nil { + ns = &namespace{} + s.Namespaces[nsName] = ns + } + } +} + // validate validates that the values specified in the desired state are valid according to the desired state spec. // check https://github.com/Praqma/helmsman/blob/master/docs/desired_state_specification.md for the detailed specification func (s *state) validate() error { From e0c19aebbeeabf6bb955ae5c3bd4ddca2eec3fc6 Mon Sep 17 00:00:00 2001 From: Mateusz Kubaczyk Date: Tue, 24 Nov 2020 12:26:44 +0100 Subject: [PATCH 2/2] Remove redundant variable for initializing namespaces step --- internal/app/state.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/app/state.go b/internal/app/state.go index b13cc232..72fa0f7d 100644 --- a/internal/app/state.go +++ b/internal/app/state.go @@ -71,8 +71,7 @@ func (s *state) setDefaults() { func (s *state) initializeNamespaces() { for nsName, ns := range s.Namespaces { if ns == nil { - ns = &namespace{} - s.Namespaces[nsName] = ns + s.Namespaces[nsName] = &namespace{} } } }