0

I'm having a problem in replacing/substituting a boolean and array variable in yaml. I'm working in argocd yaml file.

values:
          files: 
             - 'values.yaml'
             - 'values-stage.yaml'
          automated:
            - name: prune
              type: boolean
              value: true


valueFiles: {{values.files}}   ##Should receive array </code>

prune: {{values.automated.prune}} ##Should receive array </code>

How can I put values.files in valueFiles and values.automated.prune to prune?

Cloudziu
  • 475
  • 3
  • 8
Ash Poblete
  • 21
  • 1
  • 2

1 Answers1

0

It seems that anchor/alias feature can handle this.

# example.yaml

values:
  files: &files 
    - 'values.yaml'
    - 'values-stage.yaml'
  automated: &automated
    - name: prune
      type: boolean
      value: true


valueFiles: *files
# It seems there is no 'values.automated.prune' field.
valueAutomated: *automated

I have tested it with yq:

yq eval '. | explode(.)' example.yml

which gives:

values:
  files:
    - 'values.yaml'
    - 'values-stage.yaml'
  automated:
    - name: prune
      type: boolean
      value: true
valueFiles:
  - 'values.yaml'
  - 'values-stage.yaml'
valueAutomated:
  - name: prune
    type: boolean
    value: true

NOTE: YAML aliases can reference only the node that has an anchor on it, not a specific entry of the node.

Jinux
  • 177
  • 1
  • 1
  • 12