change template delimiters
changed delimiters from "{{", "}}" to "{{+", "+}}", to avoid parsing the vault templates Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -43,9 +43,9 @@ like a version on the fly.
|
|||||||
#### Parameters
|
#### Parameters
|
||||||
* `job_path`: (required) Path of the HCL job file to run
|
* `job_path`: (required) Path of the HCL job file to run
|
||||||
* `vars`: { [key: string]: string } dictionary of variables to substitute in the job file. Each key
|
* `vars`: { [key: string]: string } dictionary of variables to substitute in the job file. Each key
|
||||||
should be represented in the job file as `{{.key}}`
|
should be represented in the job file as `{{+.key+}}`
|
||||||
* `var_files`: { [key: string]: string } dictionary of paths to files to read to get variable
|
* `var_files`: { [key: string]: string } dictionary of paths to files to read to get variable
|
||||||
values. Each key should be represented in the job file as `{{.key}}` and the values should be path
|
values. Each key should be represented in the job file as `{{+.key+}}` and the values should be path
|
||||||
to text files which content will be used as the variable value. Whitespace and trailing newlines
|
to text files which content will be used as the variable value. Whitespace and trailing newlines
|
||||||
will be trimmed from the value.
|
will be trimmed from the value.
|
||||||
* `templating`: { bool }: Whether to use templating or not. `true` by default
|
* `templating`: { bool }: Whether to use templating or not. `true` by default
|
||||||
@@ -103,10 +103,10 @@ job "sample" {
|
|||||||
driver = "docker"
|
driver = "docker"
|
||||||
|
|
||||||
config {
|
config {
|
||||||
image = "cioplenu/sample:{{.version}}"
|
image = "cioplenu/sample:{{+.version+}}"
|
||||||
auth = {
|
auth = {
|
||||||
username = "some-username"
|
username = "some-username"
|
||||||
password = "{{.registry_token}}"
|
password = "{{+.registry_token+}}"
|
||||||
}
|
}
|
||||||
force_pull = true
|
force_pull = true
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ func main() {
|
|||||||
templFile, err := ioutil.ReadFile(templPath)
|
templFile, err := ioutil.ReadFile(templPath)
|
||||||
common.Check(err, "Could not read input file "+templPath)
|
common.Check(err, "Could not read input file "+templPath)
|
||||||
if config.Params.Templating != false {
|
if config.Params.Templating != false {
|
||||||
tmpl, err := template.New("job").Parse(string(templFile))
|
tmpl, err := template.New("job").Delims("{{+", "+}}").Parse(string(templFile))
|
||||||
common.Check(err, "Error parsing template")
|
common.Check(err, "Error parsing template")
|
||||||
|
|
||||||
for name, path := range config.Params.VarFiles {
|
for name, path := range config.Params.VarFiles {
|
||||||
|
Reference in New Issue
Block a user