02.07.2019       Выпуск 289 (01.07.2019 - 07.07.2019)       Интересные проекты, инструменты, библиотеки

Konfetti - управляем конфигурацией проекта+ Vault

Читать>>




Экспериментальная функция:

Ниже вы видите текст статьи по ссылке. По нему можно быстро понять ссылка достойна прочтения или нет

Просим обратить внимание, что текст по ссылке и здесь может не совпадать.

🎊konfetti🎊

codecov Build Version Python versions License

Description

konfetti is a Python configuration management system with an intuitive API, lazy evaluation and (a)sync Vault support.

The interface design and features are heavily inspired by decouple, Django, envparse and dynaconf.

Key features:

  • Lazy evaluation;
  • Built-in environment variables support;
  • Built-in async Vault access support;
  • Helpers for tests.

Benefits of lazy evaluation:

  • Faster & simpler test runs; No need for evaluation the the whole project config if it is not used
  • Avoid network calls during imports until necessary;

Quickstart

To use konfetti you need to define:

  • configuration variables in a module or a class;
  • an access point;

Settings module

# app_name/settings/production.py
from konfetti import env, vault

VAULT_ADDR = env("VAULT_ADDR")
VAULT_TOKEN = env("VAULT_TOKEN")

DEBUG = env("DEBUG", default=False)
DATABASE_URI = vault("path/to/db")

The naming convention for variables names is upper case, other variables will be ignored. To work with Vault it is required to specify VAULT_ADDR and VAULT_TOKEN in the settings module.

Access point

# app_name/settings/__init__.py
from konfetti import Konfig, AsyncVaultBackend

config = Konfig(vault_backend=AsyncVaultBackend("/secret/team"))

konfetti relies on KONFETTI_SETTINGS environment variable to discover your settings module, in the case above:

export KONFETTI_SETTINGS=app_name.settings.production

Usage

The settings module/class with configuration options shouldn't be accessed directly, because the aforementioned features are implemented in the access point level.

from app_name.settings import config

async def something():
    await config.DATABASE_URI

Documentation

For full documentation, please see https://konfetti.readthedocs.io/en/latest/

Or you can look at the docs/ directory in the repository.

Python support

Konfetti supports Python 2.7, 3.5, 3.6, 3.7 and 3.8






Разместим вашу рекламу

Пиши: mail@pythondigest.ru

Нашли опечатку?

Выделите фрагмент и отправьте нажатием Ctrl+Enter.

Система Orphus