Skip to content

Commit

Permalink
Don't create provided namespace
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
unguiculus committed Feb 14, 2020
1 parent ecd4546 commit 68c4006
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 68c4006

Please sign in to comment.