Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

values from "environments" section are not reachable #957

Closed
dududko opened this issue Nov 11, 2019 · 4 comments
Closed

values from "environments" section are not reachable #957

dududko opened this issue Nov 11, 2019 · 4 comments

Comments

@dududko
Copy link

dududko commented Nov 11, 2019

Problem

When I pass the object to environment values the helmfile.yaml templating fails.

Here is the example.

releases:
  - name: a-release
    namespace: {{ .Values.namespace.name  }}

environments:
  default:
    values:
      - namespace:
          name: hello-world

helmfile build output:

error during helmfile.yaml.part.0 parsing: template: stringTemplate:3:25: executing "stringTemplate" at <.Values.namespace.name>: map has no entry for key "namespace"

However it works if I pass the value with a flag --state-values-set=namespace.name=test, or when there is no nesting in values

environments:
  default:
    values:
      - namespace: hello-world

Observation

The content of {{ .Values }} is actually correct: map[namespace:map[name:hello-world]], also I can access the namespace field with {{ .Values.namespace }}, but all dict operation on this object fail.

@mumoshu
Copy link
Collaborator

mumoshu commented Nov 12, 2019

@dududko Hey! I believe this is due to how Double Rendering works.

I'm working hard to deprecate it and make a more intuitive alternative as the default in #932, but in the meantime, try moving environments to the beginning of your config, like:

environments:
  default:
    values:
      - namespace:
          name: hello-world

releases:
  - name: a-release
    namespace: {{ .Values.namespace.name  }}

@Aaron-ML
Copy link

This also appears to be an issue if you reference base: environments.yaml at the top, I have to manually merge them into the main helmfile to get the values to propagate correctly.

@mumoshu
Copy link
Collaborator

mumoshu commented Jan 15, 2022

Note: I keep getting questions like this for 2 years.

The short answer is to use --- so that the rendering order is more obvious:

environments:
  default:
    values:
      - namespace:
          name: hello-world

---

releases:
  - name: a-release
    namespace: {{ .Values.namespace.name  }}

@mumoshu mumoshu closed this as completed Jan 15, 2022
@mumoshu
Copy link
Collaborator

mumoshu commented Jan 15, 2022

Also see #2036 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants