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

(OS) Environment variable can't be used in environments file (YAML) #1141

Open
ghost opened this issue Mar 13, 2020 · 4 comments
Open

(OS) Environment variable can't be used in environments file (YAML) #1141

ghost opened this issue Mar 13, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2020

When I use the environment config as below
environments: dev: values: - environments/values-common.yaml - environments/values-dev.yaml - branch: {{ requiredEnv "GIT_CURRENT_BRANCH" }}

I can use the variable branch, but when I put this line in the file values-common.yaml, I can't use it and the variable is not set (map has no entry for key "branch")

I would be handy to use the line below in an environment file (such as values-common.yaml or values-dev.yaml in my example)

branch: {{ requiredEnv "GIT_CURRENT_BRANCH" }}

@mumoshu
Copy link
Collaborator

mumoshu commented Mar 16, 2020

Hi! I believe this is the same issue as #1142.

@ghost
Copy link
Author

ghost commented Mar 16, 2020

Hi! I believe this is the same issue as #1142.

Well, I think this is different. I have got the following situation.

helmfile.yaml

environments:
  default:
    values:
      - values.yaml
---
releases:
  - name: nginx
    chart: bitnami/nginx
    values:
      - hosts:
        - name: {{ .Values.host }}
          path: /

values.yaml

host: {{ requiredEnv "HOST" }}

I expect this will work, because the becauses the situation below works:
helmfile.yaml

environments:
  default:
    values:
      - host: {{ requiredEnv "HOST" }}
---
releases:
  - name: nginx
    chart: bitnami/nginx
    values:
      - hosts:
        - name: {{ .Values.host }}
          path: /

@pchristos
Copy link

pchristos commented Mar 18, 2020

Anything new on this one? It seems to me kind of a different situation, as well, no?

Here's another scenario:

Case 1

releases:                                                                          
- name: foo                                                                     
  chart: stable/foo                                                             
  values:                                                                          
  - x.bar: {{ env "BAR" }}           
  - x.baz: {{ env "BAZ" }}                                   

If BAR and BAZ are set, the above will render as expected - x.bar and x.baz will not be empty.

Case 2

releases:                                                                          
- name: foo                                                                     
  chart: stable/foo                                                             
  values:                                                                          
  - config.yaml.gotmpl                                 

where config.yaml.gotmpl is:

x:
  bar: {{ env "BAR" }}           
  baz: {{ env "BAZ" }}                                   

In this case both x.bar and x.baz will be empty. Is this the expected behavior?

What prevents OS environment variables from being available/rendered in both cases?

What's different compared to the docs?

Thanks in advance!

@pchristos
Copy link

It turns out that x.bar was empty, because the contents of config.yaml.gotmpl were:

x:
  bar: {{ env "BAR " }}           

Notice the whitespace.

Not sure how this should be handled, since env variable names do not include whitespaces by convention.

vrozaksen added a commit to vrozaksen/home-ops-1 that referenced this issue Jan 31, 2025
joryirving pushed a commit to joryirving/home-ops that referenced this issue Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants