基于适配器的配置处理程序(支持env和awssm)。
blinkistconfig的Python项目详细描述
blinkist配置python
这个包简化了对不同配置存储的访问。当前支持的存储包括: env-从应用程序的环境变量读取 SSM-从AWS SSM参数存储读取
用法
环境
importblinkistconfig.Config# Setup the Config to use the ENV as config storeconfig=blinkistconfig.Config(env="development",app_name="my_nice_app",adapter_type="ENV")my_config_value=config.get("some/folder/config")# This is being translated to ENV["SOME_FOLDER_CONFIG"]
SSM
对于ssm,此工具模拟每个应用程序的命名空间/目录功能 有自己的。默认情况下,在应用程序中请求参数myparam1 调用my_nice_app将查询ssm参数存储/application/my_nice_app/myparam1。
这与ssm param store进行前缀搜索的能力很好地协调。 /application/my_nice_app前缀是默认的“private”作用域。
importblinkistconfig.Config# setup the Config to use the SSM as config storeconfig=blinkistconfig.Config(env="development",adapter_type="SSM",app_name="my_nice_app")my_config_value=config.get("some/folder/config")# This will try to get a parameter from SSM at "/application/my_nice_app/some/folder/config"
也可以有其他作用域,可能在应用程序之间共享。 例如
my_config_value = config.get("another/config", scope="global")
# This will replace `my_nice_app` with `global` and try to resolve "/application/global/another/config"
开发
安装开发需求
pip install -r requirements/dev.txt pip install -e .
运行测试
AWS_DEFAULT_REGION="us-east-1" pytest --spec
贡献
github上的https://github.com/blinkist/blinkist-config-python欢迎错误报告和请求拉取。
许可证
根据MIT License的条款,该包可以作为开放源码提供。