Closed yorinasub17 closed 2 years ago
@yorinasub17 even the individual escape didn't work. I have tried a few other ways too.
The actual problem is that boilerplate is doing a two-step rendering 1) does the variable substitution using go template. 2) runs the sprig function on top of the value.
On the second pass, boilerplate is looking up for workflow
as a function.
ERROR: template: params.env:4: function "workflow" not defined
boilerplate version v0.3.9
Ah I see the bug here now. If you are trying to do this in a variable value, then you are actually running into an issue with our feature which recursively renders the variable. When rendering templates in a variable value, boilerplate
recursively renders that template if it continues to detect template syntax.
I'll see if we can fix this up so it works for both the original use case the recursion was intended for, and this case you are running into.
Side note: this feature exists to support nested variable references. Consider the following example:
variables:
- name: AWSRegion
default: "us-east-1"
- name: RegionFolder
default: "dev/{{ .AWSRegion }}"
- name: EnvFolder
default: "{{ .RegionFolder }}/dev"
In this scenario, boilerplate continuously renders the value of EnvFolder
template until it can get the final result because of all the nested template references.
We want to output the literal string
"artifacts/{{workflow.name}}"
without any template processing, but can't do it with the standard way go templates suggests of"artifacts/{{ "{{workflow.name}}" }}"
, leading to an error where it tries to interpret the inner{{}}
string.The workaround is to individually escape
{{
, but that is very ugly:Any way we can make the first syntax work?