Is there a way to test that the templating works fine for all the possible values?
(note: this is different from helm test which is used for testing the deployed chart through arbitrary code ran in a job).
What I would like to achieve is iterating over a set of values and checking the generated K8s resources for each.
Lets say we want to test whether our chart is correctly written:
The chart:
Values.yaml
app:
port: 8081
pod2:
enabled: true
AppPod.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: AppPod
labels:
app: nginx
spec:
...
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: {{ $.Values.app.port| default 8080 }}
Pod2.yaml
{{- if $.Values.pod2.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: Pod2
labels:
app: nginx2
spec:
...
{{- end}}
We want to run the following tests:
- with the default Values.yaml -> assert port=8081 and Pod2 is created
- With app.port missing -> assert port=8080
- With pod2.enabled false -> assert Pod2 is not created
- With pod2 missing -> test will fail because the key 'pod2' is mandatory
So basically to test the templating logic.
What I am doing right now:
Whenever I modify something in the chart I just run helm template for different Values.yaml and check the results by hand. Doing this by hand is error prone and it becomes more time consuming the more template the chart contains.
Is there any builtin helm feature or a separate framework for this?