Skip to main content
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]"

For command-line and yaml support:

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

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 look at few examples.

<your-awesome-app>
    |____<prod>
           |___<LOG_LEVEL -> "WARNING">
           |___<LOG_FILE_HANDLER -> 1>

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:

Bash:

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

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

export LOG_LEVEL='WARNING' LOG_FILE_HANDLER='1'

Yaml:

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

LOG_LEVEL: WARNING
LOG_FILE_HANDLER: 1

Json:

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

{"LOG_LEVEL": "WARNING", "LOG_FILE_HANDLER": 1}
$ rconfig -h localhost -a access-key -k 'your-awesome-app/prod' export -f json:pretty

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

Metadata

Release files for python-rconfig 20.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-rconfig 20.2.7
File Size Uploaded
python_rconfig-20.2.7.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-rconfig 20.2.7
File Interpreter ABI Platform
python_rconfig-20.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / python_rconfig-20.2.7.tar.gz

Download URL python_rconfig-20.2.7.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
38df2a250c04b5b92062047185f9807b27ef7d726bcac6863375f6802d567dfe
BLAKE2b-256 checksum
How to use checksums
9527cafde97ea0a68e33d9d6103814de1edf0f761ccd32fb9da26c79b54824c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-45-generic

Release files / python_rconfig-20.2.7-py3-none-any.whl

Download URL python_rconfig-20.2.7-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8111fe37ab636de8423deb3b4456ba72536f57846076d4de72ae1af707ff966c
BLAKE2b-256 checksum
How to use checksums
ffd9a5fd8064e9bb932fcc4744aa5092c43f7228b3545f7ee6c91740dca3230e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-45-generic

Release history Release notifications | RSS feed

This release

20.2.7 This release

2 release files

20.2.6

2 release files

20.2.4

2 release files

20.2.3

2 release files

20.2.2

2 release files

20.2.0

2 release files

20.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page