3

I have the following in my dep.yml {{ toYaml .Values.volumes | indent 8 }} which takes an array from values.yml of volumes and then loads it on the dep.yml file.

I want the following result on my dep.yml from the initial array

 volumes:
    - name: volume
      persistentVolumeClaim:
        claimName: {{ Release.Name }}-volume-claim
    - name: volume-a
      persistentVolumeClaim:
        claimName: {{ Release.Name }}-volume-a-claim
    - name: volume-b
      persistentVolumeClaim:
        claimName: {{ Release.Name }}-volume-b-claim

Adding the {{ Release.Name }} dynamically to the volume claim name for each element of the array.

Is there any way to achieve this modifying the {{ toYaml .Values.volumes | indent 8 }} directive?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
gusgleuy
  • 31
  • 1
  • 3

1 Answers1

13

Helm includes a tpl function that expands template content in a string. I would fit this into the pipeline after rendering the value to a string, but before indenting it; its parameters don't quite fit into the standard pipeline setup.

{{ tpl (toYaml .Values.volumes) . | indent 8 }}
David Maze
  • 130,717
  • 29
  • 175
  • 215