-
Notifications
You must be signed in to change notification settings - Fork 64
HCL template #25
Comments
Go's template engine would be amazing.
Sent from mobile
…On Mar 12, 2018 6:17 PM, "French Ben" ***@***.***> wrote:
As we've seen, there has been quite a few discussions around the use of a
"template engine" or something similar in order to introduce more logic to
the current template interpolation.
https://github.com/hashicorp/hcl2/blob/master/hcl/
hclsyntax/spec.md#templates
I'd like to know the motivation in re-defining yet another template
engine/syntax, when so many have been created before (and simply work) and
could be re-used?
- Go's template: https://golang.org/pkg/text/template/
- Liquid's template: https://shopify.github.io/liquid/
- Jinja's template: http://jinja.pocoo.org/
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#25>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ad1pYYn3EVQnTMqHF_xiq_pgrpdN51I2ks5tdx49gaJpZM4Sn7zE>
.
|
The constraint here is that what we define must be compatible with existing syntax in HIL. The new syntax is therefore designed to be a superset of that existing syntax so that existing Terraform configurations can work with little or no change. The interpolation syntax is used in almost every Terraform configuration and illustrated in examples all over the web and in printed books, so changing it at this point in Terraform's life is not reasonable. The other template languages mentioned here are not compatible with the HIL interpolation syntax, so while indeed we would've liked to use one of these if we had the luxury of starting from scratch, language design is often a matter of compromises. The HCL template syntax here takes inspiration from these other languages, but must also take inspiration from HIL. Syntax issues aside, it's also important to note that HCL's type system is not exactly compatible with Go's (it includes the idea of "unknown" values -- or |
@apparentlymart I understand some of the constraints/complexity listed above, yet it seems that the constraint itself has been established for no other reason than to keep everything assigned to 1 attribute: Another approach, is to check the file extensions passed to the |
@FrenchBen, I think you are discussing Terraform's It is possible that it could support other template engines in future, but that would be a matter to discuss it that provider's own repository, rather than here, since it would be a change to the implementation of that provider rather than to the HCL2 parser and interpreter. My comment above was discussing the reason why HCL2 defines templates the way it does; this is a separate question from what template engine(s) the The possibility of multiple template engines was discussed in hashicorp/terraform-provider-template#1. Nobody on the Terraform team is working on that right now because we're all busy working on other things, but that issue is a good place to discuss the implementation tradeoffs here and figure out what makes sense to implement. |
@apparentlymart understood - I ended up on the section around HCL2, from multiple github searches and the need to do more with templates. It was not my intention to steer the focus in the wrong direction, but rather provide a greater level of integration with known template formats, in order to provide greater flexibility for deploying infrastructure. Within the current docs, templates are mentioned as part of the HCL interpolation, and not as a separate provider: The confusion came from the correlation of string interpolation under the label of |
Since hashicorp/terraform-provider-template#1 is already covering the idea of having Terraform's Terraform's configuration language docs will also get an overhaul as part of preparing for its first release containing the new HCL implementation (which will be v0.12) so along the way we can try to make the relationship between the template language and the template provider a little clearer. Thanks for bringing this up! |
As we've seen, there has been quite a few discussions around the use of a "template engine" or something similar in order to introduce more logic to the current template interpolation.
https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#templates
I'd like to know the motivation in re-defining yet another template engine/syntax, when so many have been created before (and simply work) and could be re-used?
The text was updated successfully, but these errors were encountered: