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

Expand environment variables #34

Closed
marcolanaro opened this issue Feb 12, 2021 · 3 comments
Closed

Expand environment variables #34

marcolanaro opened this issue Feb 12, 2021 · 3 comments

Comments

@marcolanaro
Copy link
Contributor

🚀 Feature Proposal

It would be great to add the ability to interpolate variables.

Motivation

Often boxes come with some env variables that you want to use to declare other environment variables.

Example

Given the machine comes with an env variable like the following:

K8S_NAMESPACE=my_k8s_namespace

When in .env file we define the following

SERVICE_URL=https://prefix.$K8S_NAMESPACE.my.domain.com

Then the variable should be valued like:

SERVICE_URL=https://prefix.my_k8s_namespace.my.domain.com

This could be done in the app code, but consider the scenario where for local development the service url needs to have the following value:

SERVICE_URL=https://some.staging.environment.my.domain.com

In this case the app code should check the type of environment and then declare different strategies. It would be useful to just declare composable variables in the .env file.

Help

I could open a PR if you agree with the implementation.
From my point of view env-schema should provide a boolean expand options defaulted to false. When expand=true, internally use dotenv-expand.

@mcollina
Copy link
Member

+1, would you like to send a PR?

@marcolanaro
Copy link
Contributor Author

Brilliant!
PR opened here #36.

@mrlectus
Copy link

mrlectus commented May 8, 2024

🚀 Feature Proposal

Help

I could open a PR if you agree with the implementation. From my point of view env-schema should provide a boolean expand options defaulted to false. When expand=true, internally use dotenv-expand.

Why should it default to false? is there some performance issue?

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

3 participants