Skip to content

Unexpected rendering issue for v1 mode #807

Description

@gakesson

Operating system

Ubuntu 20.04.4 LTS

Helmfile Version

0.152.0

Helm Version

3.11.2

Bug description

I've started to look into our helmfile v1 mode and bumped into an issue.

In the attached helmfile.yaml.gotmpl the $configDir variable is added as a value, and within same yaml document the environments (attached envs.yaml) section is loaded, which uses the configDir previously added .Values. However, in v1 mode this fails with:

in ./helmfile.yaml.gotmpl: error during helmfile.yaml.gotmpl.part.0 parsing: template: stringTemplate:9:6: executing "stringTemplate" at <tpl (readFile $envFile) .>: error calling tpl: template: stringTemplate:4:18: executing "stringTemplate" at <.Values.configDir>: map has no entry for key "configDir

Without v1 mode it works fine, i.e. configDir in .Values is instantly exposed to the envs.yaml rendering, even if adding of configDir to .Values is done within same yaml document as the envs.yaml rendering.

Using attached files this can be reproduced by:

export HELMFILE_V1MODE=true && helmfile -e prod template

It is working with:

export HELMFILE_V1MODE=false && helmfile -e prod template

Example helmfile.yaml

helmfile.yaml.gotmpl :

{{ $configDir := default (env "CONFIG_DIR") | default "config" }}
values:
- configDir: {{ $configDir }}
{{ tpl (readFile (printf "%s/envs.yaml" $configDir)) . }}
---
repositories:
- name: incubator
  url: https://charts.helm.sh/incubator
---
releases:
- name: service-a
  chart: incubator/raw
  values:
  - resources:
    - apiVersion: v1
      kind: ConfigMap
      metadata:
        name: raw1
        namespace: default
      data:
        foo: {{ .Values | get "some-random-key" "" }}

envs.yaml :

environments:
  prod:
    values:
      - {{ .Values.configDir }}/envs/prod/values.yaml

config/envs/prod/values.yaml :

some-random-key: with-some-random-value

Error message you've seen (if any)

in ./helmfile.yaml.gotmpl: error during helmfile.yaml.gotmpl.part.0 parsing: template: stringTemplate:9:6: executing "stringTemplate" at <tpl (readFile $envFile) .>: error calling tpl: template: stringTemplate:4:18: executing "stringTemplate" at <.Values.configDir>: map has no entry for key "configDir

Steps to reproduce

See bug description

Working Helmfile Version

N/A

Relevant discussion

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions