【问题标题】:Is it possile to create yaml object from helm from file是否可以从文件中的 helm 创建 yaml 对象
【发布时间】:2020-03-12 23:29:47
【问题描述】:

我想遍历文件中定义的 Yaml 列表,并在 Job 中使用它。例如我有

test.yaml

    list:
      - first element
      - second element

In _helpers.tpl i can define 
something like 

{{- define "mychart.list" -}}
{{ .Files.Get "test.yaml"| toYaml }}
{{- end }}

And then in Job i want do something like 

    {{- $lists  := include "mychart.list" . }}
    {{- range $element := $lists.list}}
    apiVersion: batch/v1
    kind: Job
    metadata:


and then use the $element.

But when i am trying to do the dry-run with --debug it complains about 

at <$lists.list>: can't evaluate field list in type string.

Looks like whole value is coming as string rather than Yaml, does it needs explicit call to Yaml parser ? If yes, is there a way to do that ?

BTW i have also tried various combinations of 

    {{- $lists  := include "mychart.list" . | toYaml }}

或内联加载文件,但它们都没有帮助。

我可以将列表放在 Values.yaml 中,但不想故意这样做。

非常感谢任何帮助。

【问题讨论】:

    标签: kubernetes-helm helm-tls


    【解决方案1】:

    仅供参考,如果有人来看看。

    有 fromYaml 函数,未记录。我发现它很难,但这解决了问题。

    {{- $lists := 包括 "mychart.list" 。 |来自Yaml}}

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      • 1970-01-01
      • 1970-01-01
      • 2015-12-22
      • 1970-01-01
      相关资源
      最近更新 更多