Merge multiple yaml list to one list in helm

4/8/2019

menuconfig.yaml

---
common:
  menubar:
    - id: "1"
      title: "common"
type:
  menubar:
    - id: "3"
    - id: "4"
state:
  menubar:
    - id: "5"
    - id: "6"   

My yaml file looks like above and I need to merge all the menubar list to one in menubar list like below

---
menubar:
  - id: "1"
    title: "common"
  - id: "3"
  - id: "4"
  - id: "5"
  - id: "6"

{{ $root := . }}
{{- $v := $root.Files.Get "configfiles/menuconfig.yaml" | fromYaml }}
{{- $menubar := ($v.common.menubar) }}
{{if eq .Values.type "type"}} {{- $typemenu := $v.type.menubar }} {{- $menubar := append $menubar $typemenu }} {{end}}

My sample code looks above. I have tried to append or join two list as one and I have tried with join and append .

helm lint menulist/ works fine but join not happening while dry-run the same

Please check and let me know whether we can merge two list using template functions in helm. Plesae comment if you need more informations. Thanks in advance.

-- Abdul
kubernetes
kubernetes-helm

0 Answers