Skip to main content

Helps bring configuration, stored remotely on a ``Consul`` server, to your application

Project description

https://travis-ci.org/ArtemAngelchev/python-rconfig.svg?branch=master https://coveralls.io/repos/github/ArtemAngelchev/python-rconfig/badge.svg?branch=master https://badge.fury.io/py/python-rconfig.svg http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat

rconfig helps bring configuration, stored remotely on a Consul server, to your application.

Installation

Install the latest version with:

pip3 install -U python-rconfig

For command-line support, use the CLI option during installation:

pip3 install -U "python-rconfig[cli]"

Usage

First off all rconfig expects that you have the following key structure on the consul server:

<root-key>
    |____<common-config-key>
    |          |
    |          |___<some-env-key>
    |          |           |_____<key-value>
    |          |           |_____<key-value>
    |          |
    |          |___<another-env-key>
    |                      |_____<key-value>
    |                      |_____<key-value>
    |____<app-config-key>
               |
               |___<some-env-key>
               |           |_____<key-value>
               |           |_____<key-value>
               |
               |___<another-env-key>
                           |_____<key-value>
                           |_____<key-value>

Here root key stands for the name of the project when some have multiple applications that grouped under some kind of common purpose (often when talk about microservices). Under common configuration key, you should store configurations that common to all your applications in the project, in this case, it’s much easier to change the config in one place than go to multiple.

Command-line Interface

CLI offers you an ability to load config from Consul (within a few ways) without a need of changing application code.

Usage: rconfig [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --host TEXT     Host of a consul server  [required]
  -a, --access TEXT   Access key for a consul server  [required]
  -p, --port INTEGER  Port of consul server  [default: 8500]
  -k, --key TEXT      Consul key  [required]
  --help              Show this message and exit.

Commands:
  export  Print out bash command export for all found config
  list    Show all config for given keys

Let’s see some examples.

<your-awesome-app>
    |____<prod>
           |___<-env-key>
           |___<some-env-key>

To load prod config of you-awesome-app, issue:

$ rconfig -h localhost -a access-key -k 'your-awesome-app/prod' list

{'LOG_LEVEL': 'WARNING',
 'LOG_FILE_HANDLER': 1}

To export config to different formats, use:

$ rconfig -h localhost -a access-key -k 'your-awesome-app/prod' export -f bash

export LOG_LEVEL='WARNING' LOG_FILE_HANDLER='1'
$ rconfig -h localhost -a access-key -k 'your-awesome-app/prod' export -f json

{"LOG_LEVEL": "WARNING", "LOG_FILE_HANDLER": 1}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-rconfig-20.2.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

python_rconfig-20.2.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file python-rconfig-20.2.2.tar.gz.

File metadata

  • Download URL: python-rconfig-20.2.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.0 Linux/4.15.0-1028-gcp

File hashes

Hashes for python-rconfig-20.2.2.tar.gz
Algorithm Hash digest
SHA256 1150cc8fbb49666c752ae25300755a9407471bad871a47194d1f02b14ebfbd00
MD5 c5a75f099a85aef2f5c7b739f8eaad6b
BLAKE2b-256 9542855515baddcf15bf8ab9007fd97879341629e297c9f29cc6385f9a488d19

See more details on using hashes here.

File details

Details for the file python_rconfig-20.2.2-py3-none-any.whl.

File metadata

  • Download URL: python_rconfig-20.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.0 Linux/4.15.0-1028-gcp

File hashes

Hashes for python_rconfig-20.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea46b83f5bcaa29687baba2a25eb4ffc4eb54fc516827e7d0eba4b0366ac4bca
MD5 86301620197d1d7f946c5e2eb172b99f
BLAKE2b-256 dd722547d1bd386b1d1914fa482f207f725e8a64636079219e4c16053b21ebe3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page