Search code examples
kubernetes-helmgo-templatessprig-template-functions

How do I concatenate strings inside a variable assignment?


I'm trying to assign the output of a function to a var and append to the string at the same time but can't figure out the right syntax.

None of these examples work:

{{- $myvar := include "mychart.helper" . "-myprefix" -}}
{{- $myvar := {{include "mychart.helper" .}} "-myprefix" -}}
{{- $myvar := (include "mychart.helper" .) "-myprefix" -}}

Solution

  • It seems the right way to do this is to use the print() function

    {{- $myvar := print (include "mychart.helper" .) "-myprefix" -}}