mirror of
https://github.com/helm/chart-testing.git
synced 2026-02-06 03:45:08 +01:00
* Return correct exit code when using values files
The return values from the individual calls to `lint_chart_with_single_config`
are masked by the other operations in the `lint_chart_with_all_configs`
function.
When `helm lint` reports an error to STDERR but the chart is incorrectly
given a success tick and the exit code of `chart_test.sh` is 0 for
success. An example using `quay.io/helmpack/chart-testing:v1.1.0`:
==> Linting charts/nomad-server
[ERROR] templates/: render error in "nomad-server/templates/nomad-server.yaml": template: nomad-server/templates/nomad-server.yaml:55:28: executing "nomad-server/templates/nomad-server.yaml" at <{{template "fullname...>: template "fullname" not defined
Error: 1 chart(s) linted, 1 chart(s) failed
--------------------------------------------------------------------------------
✔︎ charts/nomad-server
--------------------------------------------------------------------------------
dcarley@cci-mbp ~/p/g/s/g/c/circle-external-services-chart master echo $?
0s
Fix this by copying the pattern used in other functions of tracking
failures in a local boolean variable and using that to determine the
return code at the end of the function. This is the result after:
==> Linting charts/nomad-server
[ERROR] templates/: render error in "nomad-server/templates/nomad-server.yaml": template: nomad-server/templates/nomad-server.yaml:55:28: executing "nomad-server/templates/nomad-server.yaml" at <{{template "fullname...>: template "fullname" not defined
Error: 1 chart(s) linted, 1 chart(s) failed
--------------------------------------------------------------------------------
✖︎ charts/nomad-server
--------------------------------------------------------------------------------
✘ dcarley@cci-mbp ~/p/g/s/g/c/circle-external-services-chart master echo $?
1
There are probably other bugs like this. Shell scripting does not
provide safe error handling for these cases and it's difficult to write
unit tests for. This is another good reason why the proposal in #29 to
re-implement in another language is a good idea.
Signed-off-by: Dan Carley <dan.carley@gmail.com>
* Make error handling for functions consistent
The `|| error=true` pattern is already used in a few other places. This
makes the change from 64c1e52 consistent with the others.
Signed-off-by: Dan Carley <dan.carley@gmail.com>