将多个Yaml列表合并为一个掌舵列表

时间:2019-04-08 10:49:46

标签: kubernetes kubernetes-helm

menuconfig.yaml

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

我的Yaml文件看起来像上面,我需要将所有菜单栏列表合并到如下所示的菜单栏列表中

---
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}}

我的示例代码在上面。我试图将两个列表追加或合并为一个,并且尝试了join和append。

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

请检查并告知我们是否可以使用掌舵中的模板功能合并两个列表。 如果您需要更多信息,请给Plesae评论。 预先感谢。

0 个答案:

没有答案
相关问题