-
Notifications
You must be signed in to change notification settings - Fork 125
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
template: Add include function #429
base: main
Are you sure you want to change the base?
Conversation
3e58eb9
to
4d6dcb8
Compare
The include function allows templates to be composed of other templates. Fixes hashicorp#305
4d6dcb8
to
1171d0c
Compare
Hi @jrasell @angrycub, is this something you would consider including in the project? My company is planning on using levant extensively in our deployment stack and this would be a great help in keeping templates composable & DRY. I'm happy to make any updates needed to get this in line with the project's standards. Thanks! |
@atavakoliyext thanks for this PR; i'll try and get a first pass review done this week! |
@jrasell Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @atavakoliyext and thanks for raising this PR. I have made an initial pass without diving too deep into the code and was curious if you had looked at the go text/template nested definitions feature which would achieve this feature without the need for a custom function. The new nomad-pack implements this feature to allow for helper and partial template rendering in main templates.
@jrasell thanks for taking a look. I'm familiar with that feature of Another approach could be to add a new flag for specifying additional template files to load before executing the main template (e.g. a |
Hi @jrasell Do you have any further thoughts on the above? |
Looking into reducing boilerplate and standardization of database deployment in my nomad jobs. The I don't see myself using levant without that. It was hard not to notice the project is not maintained anymore. No HCL2 support (#398), really? Not sure what this mysterious CRT onboarding is (#447), but maybe the start of the thing levant need to bounce back. Bummer. |
I understand nomad-pack is the futur of jobfile rendering, but, waiting for it to be production ready, any chance to have this feature merged ? Levant is used today, and will likely still be in a few years. |
The
include
function allows templates to be composed of other templates.The motivation for this change is to allow composition of complex templates from simpler components. This is currently difficult because the only mechanism available for composing a template from multiple files is the
fileContents
function, which copies contents of files ad-verbatim. This requires that all parameters of the component files are known beforehand, which is often not the case, and does not allow the component templates to use inputs from variables.Fixes #305