Open Q&A
If there's no good subforum for your question - ask it here!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Monaco: full gotemplate support?

r_weber
DynaMight Leader
DynaMight Leader

Monaco doesn't seem to support the full gotemplate function when rendering JSON templates. This makes things sometime really hard. Imagine you have a template like this:

 

"executionSettings": {
"actor": "{{ .actor }}",
"queryOffset": "{{ .queryOffset | default 0}}",
"delay": "{{ .delay | default 60}}"
}

 

If in config.yml those parameters are defined they are used, if they are not defined then the default value should be used from the template. However monaco complains "function default not defined". Which tells me not a full gotemplate spec is implemented?

Certified Dynatrace Master, Dynatrace Partner - 360Performance.net
1 REPLY 1

sujit_k_singh
Champion

Hi @r_weber 

You're right, Monaco uses Go's standard (text/template) engine, not an extended template library like Sprig or Helm's. The stdlib only ships with the built-in functions; default is a Sprig function and isn't part of core Go templates, so Monaco has no way to resolve it unless the maintainers explicitly wired in Sprig's FuncMap — which it doesn't look like they have.

can you use {{ if .queryOffset }}{{ .queryOffset }}{{ else }}0{{ end }} instead of | default 0 — verbose but works with stdlib only.

Thanks,

Sujit

Dynatrace Professional Certified

Featured Posts