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

fix: support complex extra env var map #70

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

mgagliardo91
Copy link
Collaborator

There are currently two main ways to embed environment variables - extraEnvVars and extraEnvVarsMap. The former is a 1:1 mapping of the environment variable structure allowing for complex values (such as a value from a secret). The latter is a map of key/value where the value is only strings.

This PR allows the map method to support complex values.

The main reason for this is that you cannot combine lists via helm value merging functionality. Example:

# values.yaml

extraEnvVars:
  - name: A_VALUE
    value: "hello"
  - name: TEST
    value: "foo"

# values-prod.yaml
extraEnvVars:
  - name: TEST
    value: "bar"

When running helm template . -f values.yaml -f values-prod.yaml, the env var A_VALUE will be excluded as the merging of the two lists resolves by taking the latter in full, since this is no way to determine which overrides the other.

When using a map, however:

# values.yaml

extraEnvVarsMap:
  - A_VALUE: "hello"
  - TEST: "foo"

# values-prod.yaml
extraEnvVarsMap:
  - TEST: "bar"

The merged output will be:

extraEnvVarsMap:
  - A_VALUE: "hello"
  - TEST: "bar"

@mgagliardo91 mgagliardo91 requested review from ndustrial-devops, a team, kalinon and skmannion and removed request for a team October 2, 2024 15:24
@mgagliardo91
Copy link
Collaborator Author

@skmannion example of/reason for usage: https://github.com/ndustrialio/nionic-api/pull/2578

@mgagliardo91 mgagliardo91 merged commit 8c1e1e3 into main Oct 2, 2024
1 check passed
@mgagliardo91 mgagliardo91 deleted the support-complex-extra-env branch October 2, 2024 18:27
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

Successfully merging this pull request may close these issues.

2 participants