Open KostasKgr opened 2 years ago
Valid problem! I have not seen the slack discussion, but my best idea to solve this would be to simply strip any .j2
extension by default.
That would break any current users wanting to write e.g a example.j2
file to output_path, but that is maybe more of an edge case, and could be fixed by naming the input file example.j2.j2
?
The referenced PR implements stripping and so I guess what remains is more a decision about what would be the best default behavior - and again, changing it to strip .j2
by default seems sensible.
This issue is stale because it has been open for 1 year with no activity. Remove the stale label or comment if this issue is still relevant for you. If not, please close it yourself.
Describe the feature Ability to strip .j2 extension when performing jinja2 compilation. It is useful to have .j2 extension on files for at least two reasons:
If a file path is specified for output_path then this gets interpreted as a folder name. https://kapitan.dev/compile/#specifying-inputs-and-outputs
Perhaps general renaming would cover more use cases, such as compiling a template to multiple outputs in the same node or providing a better semantic name to the template.
Raising this after discussing stripping .j2 in kapitan slack channel.
I don't have some good recommendation on how to approach it, as the current interface of compile expects multiple input files and one output directory. Perhaps ansible template module can be used for inspiration: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html
To Reproduce
Output of the above would be compiled to app/my_app1/config.cfg/generic_python_config.cfg.j2
Expected behavior Able to drop .j2 extension and rename. Ouput would be compiled to app/my_app1/config.cfg
Additional context Using kapicorp/kapitan:v0.30.0-rc.0