From a42c024257b12906208829a86379e7536fca354a Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 30 Apr 2018 09:15:11 +0100 Subject: [PATCH] fix: allow an environment variable to default the deploy namespace lets allow an environment variable to be used to define the helm deploy namespace fixes #496 --- pkg/skaffold/deploy/helm.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index 1d316c29f6b..71357696450 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "io" + "os" "os/exec" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/build" @@ -106,8 +107,12 @@ func (h *HelmDeployer) deployRelease(out io.Writer, r v1alpha2.HelmRelease, b *b args = append(args, "upgrade", r.Name, r.ChartPath) } - if r.Namespace != "" { - args = append(args, "--namespace", r.Namespace) + ns := r.Namespace + if ns == "" { + ns = os.Getenv("SKAFFOLD_DEPLOY_NAMESPACE") + } + if ns != "" { + args = append(args, "--namespace", ns) } if r.ValuesFilePath != "" { args = append(args, "-f", r.ValuesFilePath)