From 7a16d1e4992962a452e778caffdb05a8b57bb6d2 Mon Sep 17 00:00:00 2001 From: Ali Koyuncu Date: Wed, 23 Aug 2023 18:43:20 +0300 Subject: [PATCH 1/2] feat: add all sprig functions to templates --- sensors/dependencies/filter.go | 2 +- sensors/triggers/params.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sensors/dependencies/filter.go b/sensors/dependencies/filter.go index 96c8cfecc1..d96341cdd3 100644 --- a/sensors/dependencies/filter.go +++ b/sensors/dependencies/filter.go @@ -238,7 +238,7 @@ filterData: } if f.Template != "" { - tpl, tplErr := template.New("param").Funcs(sprig.HermeticTxtFuncMap()).Parse(f.Template) + tpl, tplErr := template.New("param").Funcs(sprig.FuncMap()).Parse(f.Template) if tplErr != nil { if operator == v1alpha1.OrLogicalOperator { errMessages = append(errMessages, tplErr.Error()) diff --git a/sensors/triggers/params.go b/sensors/triggers/params.go index 7bda102e59..b21be85eba 100644 --- a/sensors/triggers/params.go +++ b/sensors/triggers/params.go @@ -275,7 +275,8 @@ func ResolveParamValue(src *v1alpha1.TriggerParameterSource, events map[string]* // the raw json bytes and then returns the result or any error func getValueWithTemplate(value []byte, templString string) (string, error) { res := gjson.ParseBytes(value) - tpl, err := template.New("param").Funcs(sprig.HermeticTxtFuncMap()).Parse(templString) + // add all sprig Functions to the template + tpl, err := template.New("param").Funcs(sprig.FuncMap()).Parse(templString) if err != nil { return "", err } From f578a69b6bf1ef1ae31969442fec897b95ab53bb Mon Sep 17 00:00:00 2001 From: Ali Koyuncu Date: Mon, 4 Sep 2023 08:46:42 +0300 Subject: [PATCH 2/2] chore: remove comment --- sensors/triggers/params.go | 1 - 1 file changed, 1 deletion(-) diff --git a/sensors/triggers/params.go b/sensors/triggers/params.go index b21be85eba..9334e9b431 100644 --- a/sensors/triggers/params.go +++ b/sensors/triggers/params.go @@ -275,7 +275,6 @@ func ResolveParamValue(src *v1alpha1.TriggerParameterSource, events map[string]* // the raw json bytes and then returns the result or any error func getValueWithTemplate(value []byte, templString string) (string, error) { res := gjson.ParseBytes(value) - // add all sprig Functions to the template tpl, err := template.New("param").Funcs(sprig.FuncMap()).Parse(templString) if err != nil { return "", err