From 2a1a58d10053ac090e28e4d4450f8d369143101f Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Wed, 7 Jun 2023 17:30:56 -0700 Subject: [PATCH] Allow setting namespace in `helm template` without a kubeconfig If you don't have a working kubeconfig, `helm template` does not respect the `--namespace` option. It gets set on the settings object, but does not get returned. `helm template` should not require a working kubeconfig or any communication with a kubernetes cluster. Signed-off-by: Alex Hunt --- pkg/cli/environment.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index dac2a4bc1..d8a25c18a 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -223,6 +223,9 @@ func (s *EnvSettings) Namespace() string { if ns, _, err := s.config.ToRawKubeConfigLoader().Namespace(); err == nil { return ns } + if s.namespace != "" { + return s.namespace + } return "default" }