dynaconf
dynaconf copied to clipboard
[RFC] Allow multiple envvar prefixes. was: Switch env with additional env variables
I am wondering whether it exists some simple method to switch the env label with additional env variables.
I am writing a SDK for TencentCloud. I want to the environment variables in the runtime of function computing. A environment variable, "TENCENTCLOUD_RUNTIME"="SCF"
, can be used to identify the environment. I hope to use them as additional default value or replace some addtional default value, for example, "TENCENTCLOUD_SECRETID" in replace of SDK's "QCLOUDSDK_SECRET_ID"。
I cannot understand how to use custom loader, or use proper parameters to control settings class.
In addition, the docs have no detailed description about "@str format" and "@jlina " with env. I cannot find proper ways to deal with more complicated condition, for example, "TENCENTCLOUD_SECRETID" only exists when access role is setted.
maybe what you are lokking for is dynaconf_hooks? https://www.dynaconf.com/advanced/#hooks
Revisiting this issue and IIUC this is an RFC to include something like:
- Allow multiple prefixes when loading envvars
settings = Dynaconf(envvar_prefix=["PREFIX1", "PREFIX2"])
and the order of the prefix list defines its precedence, so if both PREFIX1_KEY
and PREFIX2_KEY
exists, the first has precedence.
On #683 there will be support for setting envvars per variable defined in the schema