Skip to content

Configus - a declarative spec for configuration

Notifications You must be signed in to change notification settings

msoedov/configus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configus - a declarative contract for configuration

Instalation

pip install configus

Features

  • Unified spec for process config

  • Strict validation of config, no more trailing whitespaces or runtime panics from malphormed uri's

  • Support parametrization from env variables and cli arguments at the same time.

    • The same param could passed as export DEBUG=on or --debug=on
  • Auto load of .env file

  • Easy to mock for unit tests

Usage

Let start with a simple spec that our requires debug, version and secret_cookie configuration params

# app.py
from configus import config, trafaret as t

if __name__ == '__main__':
    # Describes shape of the data params which will be taken either from env, cli args or envfile.
    schema = t.Dict(DEBUG=t.StrBool, VERSION=t.Float, SECRET_COOKIE=t.String)
    env_vars = config(schema=schema)
    assert env_vars == {'DEBUG': True, VERSION: 0.1, SECRET_COOKIE=<......>}

Once schema defined we can pass variables throw env

DEBUG=1 VERSION=1.0 SECRET_COOKIE=yo python app.py

Cmd flags

python app.py --debug=1 version=1.0

Or even both

export VERSION=1.0
export SECRET_COOKIE=yo
python app.py --debug=2

About

Configus - a declarative spec for configuration

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages