https://github.com/david-lor/pydantic-etcd
Class-based settings loader with ⚙️ETCD support, working from 🤓pydantic's BaseSettings class
https://github.com/david-lor/pydantic-etcd
Last synced: 10 months ago
JSON representation
Class-based settings loader with ⚙️ETCD support, working from 🤓pydantic's BaseSettings class
- Host: GitHub
- URL: https://github.com/david-lor/pydantic-etcd
- Owner: David-Lor
- License: apache-2.0
- Created: 2020-02-15T09:29:39.000Z (almost 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-04-11T14:42:53.000Z (almost 6 years ago)
- Last Synced: 2025-02-03T23:49:05.363Z (11 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pydantic-etcd

[pydantic](https://github.com/samuelcolvin/pydantic) BaseSettings - based class to load settings from an ETCD server.
**This image is experimental and might have undesirable effects. Currently is more a POC than a functional project.
Use it under your responsability!**
## Getting started
PUT these two keys in your ETCD server: `app_host` & `app_port` (int)
Then (assuming you're running an ETCD server on localhost), run:
```python
from pydantic_etcd import ETCDSettings, BaseETCDSettings
class MySettings(BaseETCDSettings):
app_host: str
app_port: int
etcd_settings = ETCDSettings(host="127.0.0.1", port=2739)
settings = MySettings(etcd_settings)
print("App host:", settings.app_host)
print("App port:", settings.app_port)
```
See more examples at [examples](examples).
## Changelog
- 0.0.1 - Initial version, load from ETCD and watch keys
## TODO
- Standarize priority of loading from environment variables and ETCD
- Support ETCD authentication (and other settings...)
- Support ETCD prefix
## Requirements
- Python >=3.6
- Requirements listed in [requirements.txt](requirements.txt)
- Running ETCD server
## Installing
While package is not uploaded to PyPi, can be installed with:
```bash
pip install git+git://github.com/David-Lor/pydantic-etcd.git#egg=pydantic-etcd
```
Or cloning the repo:
```bash
git clone https://github.com/David-Lor/pydantic-etcd.git
cd pydantic-etcd
python setup.py install
```
## Running tests
```bash
# Ensure you have a working ETCD server!
pip install -r requirements.txt
pip install -r requirements.test.txt
pytest .
```