I have a helm chart which has a CRD yaml as follows
.......
.......
arguments:
parameters:
- name: {{ .Values.workflow_template_command_name }}
value: "echo '{{ .Values.notebook_details }}'| jq .run_id > /tmp/info.txt"
.......
.......
The string variable notebook_details in values.yaml has a placeholder which I would like to replace with another variable defined in values.yaml.
something like this?
value: "echo '{{ .Values.notebook_details |replace 'PLACEHOLDER' .Values.text }}'| jq .run_id > /tmp/info.txt"
Is it possible? if so, whats the right syntax?
The Helm documentation includes a Template Function List; if you look at the list of string functions, there is a replace function.
If you want to take the string from .Values.notebook_details, and replace the string literal PLACEHOLDER with the value in .Values.text, the template syntax is almost exactly what you have, but with double quotes around the string literal (it doesn't matter that it's in a double-quoted YAML string):
value: "echo '{{ .Values.notebook_details | replace "PLACEHOLDER" .Values.text }}' | jq ..."
Another approach to consider is to allow Helm templating in the value itself. Documented elsewhere is the Helm tpl template function which will evaluate a string as a template
value: "echo '{{ tpl .Values.notebook_details . }}' | jq ..."
# values.yaml
notebook_details: The text is {{ .Values.text }}.
text: replaced by the `tpl` function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With