Expand environment variables
marcolanaro opened this issue ยท 3 comments
๐ 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.
+1, would you like to send a PR?
Brilliant!
PR opened here #36.