Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create provided namespace #205

Merged
merged 5 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 5 additions & 0 deletions pkg/chart/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func TestInstallChart(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
ct := newTestingHelmIntegration(tc.cfg)
namespace := tc.cfg.Namespace
if namespace != "" {
ct.kubectl.CreateNamespace(namespace)
defer ct.kubectl.DeleteNamespace(namespace)
}
result := ct.InstallChart(mustNewChart(tc.chartDir))

if result.Error != tc.output.Error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nginx.fullname" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
clusterIP: None
ports:
- port: {{ .Values.service.port }}
targetPort: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ include "nginx.fullname" . }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nginx.name" . }}
Expand Down