jlandowner / helm-chartsnap

Snapshot testing tool for Helm charts
MIT License
15 stars 3 forks source link

Failed to snapshot helm `required` error output #109

Closed florianrusch closed 4 months ago

florianrusch commented 4 months ago

Hello again,

today I wanted to integrate helm-chartsnap into another project where I discovered an edge case that I'm not sure how to handle.

Let's imagine we have a template that contains the following:

testValue: {{ required "testValue is required" .Values.testValue }}

and a values.yaml that contains the following:

testValue:

Executing helm template and also helm chartsnap -c . would now result in the following "error" message:

Error: execution error at (<TEMPLATE_PATH>.yaml:1:3): testValue is required

The question now is, how should I handle this? I don't want to put a default value in the values.yaml because there is no "default" value as the value always depends on the environment the helm chart will applied to.

One idea would be to provide a separate "default" values.yaml file just for chartsnap. But this feels somehow ugly for me. Also I would need to provide testValue in each of my test values.yaml files which is very repetitive.

Another idea would be to somehow provide these kind of values within the .chartsnap.yaml, but I guess that's not supported at the moment, right?

jlandowner commented 4 months ago

Hi @florianrusch, thank you for raising!

charsnap should take all the output of helm as snapshot. So What I expect is to successfully snapshot the required error.

It looks charsnap failed to handle helm error exitcode. I will investigate.