An extension for python-decouple to read Consul using python-consul2.
Project description
An extension for python-decouple to read Consul using python-consul2.
pip install consul-decouple
How it works
Read config from environment;
If it’s connected with Consul, it’ll read the config from there;
python-decouple behavior:
Repository: ini or .env file;
default argument passed to config;
How to use
Read Consul settings from enviroment. CONSUL_HOST=host, CONSUL_PORT=port, CONSUL_TOKEN=token, CONSUL_SCHEME=scheme
from consul_decouple import config
my_key = config('my_bool_key', cast=bool, default=False)
Creating a custom Consul connection
from consul import Consul
from consul_decouple import AutoConfig
consul = Consul(host='127.0.0.1', port=8500, token=None, scheme='http')
config = AutoConfig(consul)
my_key = config('my_bool_key', cast=bool, default=False)
Read only one KeyValue from Consul and parse it from JSON. It’ll reads the configs from the parsed JSON
from consul_decouple import AutoConfig
config = AutoConfig(json_kv='my_key_with_json_value')
my_key = config('my_bool_key', cast=bool, default=False)
Contribute
git clone https://github.com/lucasrcezimbra/consul-decouple
cd consul-decouple
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pre-commit install
docker-compose up -d
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
consul-decouple-0.0.2.tar.gz
(12.7 kB
view hashes)