| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
| tmpl, err := template.New("cfg").Funcs(updatecliRuntimeFuncMap(data)).Parse(string(content)) | ||
| tmpl, err := template.New("cfg"). | ||
| Funcs(sprig.FuncMap()). |
There was a problem hiding this comment.
While we are here, I am wondering if you shouldn't also add the custom Helm function
updatecli/pkg/core/config/template.go
Line 49 in 7e7aaa2
| Funcs(sprig.FuncMap()). | |
| Funcs(sprig.FuncMap()). | |
| Funcs(helmFuncMap()). // add helm funcMap |
Sorry, something went wrong.
|
Thank you for the PR, it looks great especially with the tests. I just have a minor feedback to only this templating with the one happening at the beginning |
Sorry, something went wrong.
|
I don't know what happening but I just gave it a test using sources:
1:
name: echo 1.2.3
kind: shell
dependson:
- 2
spec:
command: echo 1.2.3
2:
name: echo 2.3.4
kind: shell
spec:
command: echo 2.3.4
conditions:
3:
name: 'echo {{ source "1" }}.x'
kind: shell
disablesourceinput: true
spec:
command: 'echo {{ source "1" }}'
4:
name: 'echo {{ source "1" | replace "." "_" }}'
kind: shell
disablesourceinput: true
spec:
command: 'echo {{ source "1" | replace "." "_" }}'
|
Sorry, something went wrong.
|
I just took another look and unfortunately I am not even sure it's technically possible to achieve what you need. Updatecli has two kind of templating, one at start time and a second one after each resource execution to leverage dynamic information like source result. Because the templating engine doesn't know when a resource is executed, we are using this trick If a source hasn't been executed yet, then the template returns '{{ source "sourceID"}}', so in the current implementation it would drop any additional filters like replace "." "_" |
Sorry, something went wrong.
|
Worth mentioning your tests are passing because it's executed at start time but with source result which never happen in reality |
Sorry, something went wrong.
|
Thanks for the quick review and for looking into this! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix #6789
Enable pipe operations on {{ source }} function output to allow transformation of source values at runtime using sprig template functions.
Changes
Example
Test
To test this pull request, you can run the following commands:
Additional Information
Checklist
Tradeoff
No breaking changes. All existing {{ source }} usage continues to work. Adding sprig functions to runtime templates provides flexibility with minimal performance impact.
Potential improvement