Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only .yaml template files are supported #146

Open
rlaveycal opened this issue Jan 7, 2022 · 2 comments · May be fixed by #147
Open

Only .yaml template files are supported #146

rlaveycal opened this issue Jan 7, 2022 · 2 comments · May be fixed by #147

Comments

@rlaveycal
Copy link

There is a switch statement

switch filepath.Ext(file) {

that adds rendered files to the manifest used by the test engine. This filters on the file extension of the template file and only supports .yaml and .txt. Any other extension (e.g. .yml, .tpl) is silently ignored.

This caused me a lot of grief as my templates were .tpl and I got the error template "test-chart/templates/web.tpl" not exists or not selected in test suite when running my tests.

I suggest the following:

  1. .yml and .tpl are added to .yaml
  2. A default: is added to the switch to log that extension X is not supported and has been ignored
rlaveycal added a commit to rlaveycal/helm-unittest that referenced this issue Jan 7, 2022
add yml and tpl to supported file extensions
write a warning when files are ignored

Signed-off-by: Richard Lavey <richard.lavey@calastone.com>
@rlaveycal rlaveycal linked a pull request Jan 7, 2022 that will close this issue
@armingerten
Copy link

regarding .tpl: A .tpl itself does not generate any output, so IMHO it must not be included in the switch-case block. If template functions from .tpl are included in a manifest template, the unit case should test the resulting manifest instead. Testing the template function from the .tpl file directly feels similar to testing / trying to test private methods in a C-like language... This is rather an implementation details and not a visible property of the unit under test.

regarding .yml: The official Helm Best Practices Guide suggest templates to have the extension .yaml. I suppose .yml is technically a valid extensions, however discouraged.

@rpieczon
Copy link

Can you merge this PR? I do not see a reason why provided change cannot be delivered.

helm-unittest comes with test which perfectly matches to this problem, the only one difference is that input file has .yaml extension:

https://github.com/quintush/helm-unittest/blob/master/test/data/v3/basic/tests_failed/deployment_test.yaml

d3adb5 pushed a commit to d3adb5/helm-unittest-tests that referenced this issue Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants