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

Support dependent env vars #390

Merged
merged 3 commits into from
Mar 4, 2021
Merged

Support dependent env vars #390

merged 3 commits into from
Mar 4, 2021

Conversation

marcinc
Copy link
Contributor

@marcinc marcinc commented Mar 4, 2021

Resolves: #391

Compose Environment variables which values are dependent on other environment variables must be ordered properly so that they can be expanded correctly. This PR allows for env variables with templated values that reference other environment variables, e.g.

# docker-compose.yaml

environment:
  MY_VAR: {{FOO}}/{{BAR}}
  FOO: foo
  BAR: bar

In k8s manifest this will translate to:

    spec:
      containers:
        - env:
            - name: FOO
              value: "foo"
            - name: BAR
              value: "bar"
            - name: MY_VAR
              value: "$(FOO)/$(BAR)"

ezodude
ezodude previously approved these changes Mar 4, 2021
Copy link
Contributor

@ezodude ezodude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

ENV_VAR_B: bar
ENV_VAR_C: {{ENV_VAR_A}}/{{ENV_VAR_B}} # referencing other dependent environment variables
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This make a lot of sense.

In fact, we need this as a custom method for relying on ENV values, that will pick the value of another ENV value. Esp., that compose doesn't have a native mechanism to do this.

Copy link
Contributor

@ezodude ezodude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@marcinc marcinc merged commit 04e26de into master Mar 4, 2021
@marcinc marcinc deleted the support-dependent-env-vars branch March 4, 2021 11:42
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.

Support dependent env variables
2 participants