Is it possibe to create yaml object in helm from file


I want to iterate over the Yaml list which is defined in the file, and use it in Job. For example i have


      - 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

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

or loading the file inline, but none of them helps.

I can put the list in Values.yaml, but don't want to do that purposely.

Any help is really appreciated.

Join { to automatically receive all group messages.