Secrets are optional; chart testing

This commit is contained in:
Laszlo Fogas
2020-10-08 20:08:55 +02:00
parent a865d6408c
commit 718573cffa
5 changed files with 41 additions and 1 deletions
+1
View File
@@ -1,2 +1,3 @@
.idea/
values.yaml
manifests
+14 -1
View File
@@ -1,5 +1,18 @@
all: package
all: lint package
lint:
helm lint onechart/
kubeval:
rm -rf manifests && true
mkdir manifests
helm template onechart --output-dir manifests
find manifests/ -name '*.yaml' | xargs kubeval --ignore-missing-schemas -v 1.13.0
find manifests/ -name '*.yaml' | xargs kubeval --ignore-missing-schemas -v 1.18.0
test:
helm unittest onechart
package:
helm package onechart
+1
View File
@@ -0,0 +1 @@
tests
+2
View File
@@ -35,8 +35,10 @@ spec:
envFrom:
- configMapRef:
name: {{ .Release.Name }}
{{- if .Values.secret.enabled }}
- secretRef:
name: {{ .Release.Name }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
+23
View File
@@ -0,0 +1,23 @@
suite: test deployment
templates:
- deployment.yaml
- configmap.yaml
tests:
- it: Should reference secret if secret is enabled
set:
secret.enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].envFrom
content:
secretRef:
name: RELEASE-NAME
- it: Should not reference secret if secret is disabled
set:
secret.enabled: false
asserts:
- notContains:
path: spec.template.spec.containers[0].envFrom
content:
secretRef:
name: RELEASE-NAME