avoid empty kube-job/kube-cronjob scripts

As can be seen in !6507 (merged) (#3352 (closed)), the use of Helm Files.Get does not let us catch the case where the path we provide points to a non-existing file. As a result the patch we do on kube-job and kube-cronjob units to inject the specific script for the unit may silently inject empty content in the kube-job script.

This MR introduces a check to ensure that any such empty content will result in a clean and proper failure.

Testing

a unit test was added to ensure that this new check does its job correctly:

$ tools/validation/helm-template-yamllint.sh sylva-units '*kube-job*'
--------------- Checking values from test-values/kube-job-wrong-path with 'helm template ' and 'yamllint' ...
  running: helm template sylva-units charts/sylva-units  --values charts/sylva-units/test-values/kube-job-wrong-path/values.yaml
Error: execution error at (sylva-units/templates/units.yaml:6:31): empty kube-job script

Use --debug flag to render out invalid YAML
This negative testcase expectedly made 'helm template ..| yamllint ..' fail.
OK
Edited by Thomas Morin

Merge request reports

Loading