类型安全环境变量分析。
myenv的Python项目详细描述
MyENV: Environment Variable Parsing using Type annotations
myenv使用类型注释解析您的环境变量。 这允许您将应用程序/服务配置为 12factor.net/config,保存时 你的代码类型安全。
项目/回购:
代码质量/ci:
Name | role | since | until |
---|---|---|---|
Manuel Barkhau (mbarkhau@gmail.com) | author/maintainer | 2018-09 | - |
Environment Variables and Configuration
In order of priority, configuration is parsed from
- Environment variables
- Configuration files
- Defaults defined in source code
Declaration
The ^{
For each annoatated member of ^{
Parsing
To use the above configuration class, simply instanciate it.
^{pr 2}$In case you're worried about the instantiation of ^{
Config Files
When parsing configs, the following paths are parsed if they
exist. By default the configs are loaded from ^{
- ^{
} - ^{
}
Any variables defined in these files will be set, unless it was already set in the environ or a previous config file.
This approach allows you to satisfy typical use cases in which a service is hosted:
- Development Machine
- Stage/Production Environment
You can put use case specifc configuration files in your project source tree, such as:
- ^{
} - ^{
} - ^{
}
To parse the appropriate config file, all you have to do is set a
single environment variable ^{
The ^{
For sensitive configuration parameters, such as passwords and authentication tokens, you may prefer to write config files outside of your source tree, or to provide them always and only via environment variables.
Changelog for https://gitlab.com/mbarkhau/myenv
V201902.0007
- 打包更新
- 更好的测试和mypy覆盖率
V201812.0005-β
- 添加配置分析
- 简化实例化(无需导入myenv即可使用子类)
- 切换到https://gitlab.com/mbarkhau/myenv
- 使用https://gitlab.com/mbarkhau/bootstrapit
V201809.0001-β
- 初始版本