Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucasrcezimbra/consul-decouple
An extension for python-decouple to read Consul
https://github.com/lucasrcezimbra/consul-decouple
consul decouple python python-consul python-consul2 python-decouple
Last synced: about 17 hours ago
JSON representation
An extension for python-decouple to read Consul
- Host: GitHub
- URL: https://github.com/lucasrcezimbra/consul-decouple
- Owner: lucasrcezimbra
- License: lgpl-2.1
- Created: 2021-05-05T19:00:26.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-05-20T18:08:06.000Z (over 3 years ago)
- Last Synced: 2024-11-09T19:49:42.969Z (6 days ago)
- Topics: consul, decouple, python, python-consul, python-consul2, python-decouple
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
consul-decouple
===============.. image:: https://badge.fury.io/py/consul-decouple.svg
:target: https://badge.fury.io/py/consul-decouple
:alt: PyPIAn extension for
`python-decouple `__
to read Consul using
`python-consul2 `__... code:: bash
pip install consul-decouple
How it works
------------1. Read config from environment;
2. If it's connected with Consul, it'll read the config from there;
3. python-decouple behavior:1. Repository: ini or .env file;
2. 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.. code-block:: python
from consul_decouple import config
my_key = config('my_bool_key', cast=bool, default=False)
- Creating a custom Consul connection
.. code-block:: python
from consul import Consul
from consul_decouple import AutoConfigconsul = 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.. code-block:: python
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
----------.. code:: bash
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