From 68c400618b7968a762c8e1846798b0f97997d464 Mon Sep 17 00:00:00 2001 From: Reinhard Naegele Date: Fri, 14 Feb 2020 15:03:43 +0100 Subject: [PATCH] Don't create provided namespace Adding support for Helm 3 introduced creating namespaces because Helm does not do this automatically anymore. However, a regression was introduced that always creates namespaces, even if a dedicated namespace is provided via CLI flag. Signed-off-by: Reinhard Naegele --- pkg/chart/chart.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index ef122b02..a8353542 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -16,11 +16,12 @@ package chart import ( "fmt" - "github.com/Masterminds/semver" "io/ioutil" "path/filepath" "strings" + "github.com/Masterminds/semver" + "github.com/helm/chart-testing/v3/pkg/config" "github.com/helm/chart-testing/v3/pkg/exec" "github.com/helm/chart-testing/v3/pkg/tool" @@ -541,8 +542,10 @@ func (t *Testing) doInstall(chart *Chart) error { namespace, release, releaseSelector, cleanup := t.generateInstallConfig(chart) defer cleanup() - if err := t.kubectl.CreateNamespace(namespace); err != nil { - return err + if t.config.Namespace == "" { + if err := t.kubectl.CreateNamespace(namespace); err != nil { + return err + } } if err := t.helm.InstallWithValues(chart.Path(), valuesFile, namespace, release); err != nil { return err @@ -579,8 +582,10 @@ func (t *Testing) doUpgrade(oldChart, newChart *Chart, oldChartMustPass bool) er namespace, release, releaseSelector, cleanup := t.generateInstallConfig(oldChart) defer cleanup() - if err := t.kubectl.CreateNamespace(namespace); err != nil { - return err + if t.config.Namespace == "" { + if err := t.kubectl.CreateNamespace(namespace); err != nil { + return err + } } // Install previous version of chart. If installation fails, ignore this release. if err := t.helm.InstallWithValues(oldChart.Path(), valuesFile, namespace, release); err != nil {