Skip to content

๐Ÿ“„ Templating

Helmwave uses Go templates for templating.

Helmwave supports all built-in functions, Sprig library, and several advanced functions:

  • toYaml marshals a map into a string
  • fromYaml reads a golang string and generates a map
  • readFile get file as string
  • hasKey get true if field is exists
  • get (Sprig's original get is available as sprigGet)
  • setValueAtPath PATH NEW_VALUE traverses a golang map, replaces the value at the PATH with NEW_VALUE
  • requiredEnv The requiredEnv function allows you to declare a particular environment variable as required for template rendering. If the environment variable is unset or empty, the template rendering will fail with an error message.

readFile

my-releases.yml
releases:
  - name: redis
    repo: bitnami
  - name: memcached
    repo: bitnami
helmwave.yml.tpl
project: my
version: 0.9.1


repositories:
  - name: bitnami
    url: https://charts.bitnami.com/bitnami


.global: &global
  install: true


releases:
{{- with readFile "my-releases.yml" | fromYaml | get "releases" }}
  {{- range $v := . }}
  - name: {{ $v | get "name" }}
    chart: {{ $v | get "repo" }}/{{ $v | get "name" }}
    options:
      <<: *global
  {{- end }}
{{- end }}
helmwave yml
helmwave.yml
project: my
version: 0.9.1

repositories:
  - name: bitnami
    url: https://charts.bitnami.com/bitnami

.global: &global
  install: true

releases:
  - name: redis
    chart: bitnami/redis
    options:
      <<: *global
  - name: memcached
    chart: bitnami/memcached
    options:
      <<: *global