Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msoedov/configus
Configus - a declarative spec for configuration
https://github.com/msoedov/configus
config-validation configuration configuration-management python
Last synced: about 1 month ago
JSON representation
Configus - a declarative spec for configuration
- Host: GitHub
- URL: https://github.com/msoedov/configus
- Owner: msoedov
- Created: 2017-03-15T23:54:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-29T01:37:13.000Z (over 7 years ago)
- Last Synced: 2025-01-01T19:42:05.055Z (about 1 month ago)
- Topics: config-validation, configuration, configuration-management, python
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
Configus - a declarative contract for configuration
### Instalation
```
pip install configus
```### Features
- [x] Unified spec for process config
- [x] Strict validation of config, no more trailing whitespaces or runtime panics from malphormed uri's- [x] Support parametrization from env variables and cli arguments at the same time.
- [x] The same param could passed as `export DEBUG=on` or `--debug=on`
- [x] Auto load of `.env` file
- [x] Easy to mock for unit tests### Usage
Let start with a simple spec that our requires `debug`, `version` and `secret_cookie` configuration params
```python
# app.py
from configus import config, trafaret as tif __name__ == '__main__':
# Describes shape of the data params which will be taken either from env, cli args or envfile.
schema = t.Dict(DEBUG=t.StrBool, VERSION=t.Float, SECRET_COOKIE=t.String)
env_vars = config(schema=schema)
assert env_vars == {'DEBUG': True, VERSION: 0.1, SECRET_COOKIE=<......>}
```Once schema defined we can pass variables throw env
```shell
DEBUG=1 VERSION=1.0 SECRET_COOKIE=yo python app.py
```Cmd flags
```shell
python app.py --debug=1 version=1.0
```Or even both
```shell
export VERSION=1.0
export SECRET_COOKIE=yo
python app.py --debug=2
```