kubernetes-helmhelmfile

how to pass array in helmfile


I have helmfile

releases:
  - name: controller
    values:    
      - values/valuedata.yaml
    hooks:
      {{ toYaml .Values.hooks }}

file with values

hooks:
  - events: [ "presync" ]
    showlogs: true
    command: "bash"
    args: [ "args"]

I want to pass the hooks from values how I can do it ? I tried many ways and I got an error This is the command

helmfile --file ./myhelmfile.yaml sync   
 failed to read myhelmfile.yaml: reading document at index 1: yaml: line 26: did not find expected '-' indicator

Solution

  • What you try to do is to inline part of the values.yaml into your template. Therefore you need to take care of the indentation properly.

    In your case I think it'll be something like this:

    releases:
      - name: controller
        values:    
          - values/valuedata.yaml
        hooks:
    {{ toYaml .Values.hooks | indent 6 }}
    

    You can find a working example of a similar case here.