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 details)
File details
Details for the file consul-decouple-0.0.2.tar.gz
.
File metadata
- Download URL: consul-decouple-0.0.2.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a15304908d46ec94456de035f2a5a6525d0ebdeaee58ad595ca184894556c07 |
|
MD5 | 18093b68cec8d8c24b6375e0fd792b64 |
|
BLAKE2b-256 | 307d130ff1f5b4c2c5520c5763a8eb5e6699df8212c72fb817c837958907a62a |