Package: konfetti
Descriptionkonfettiis a Python configuration management library that simplifies the process of setting up your application to run on your company’s infrastructure.This library will help you to retrieve secrets from Vault, manages the access to settings required by our monitoring services, such as Datadog and Sentry, and set up tests for evaluating your app’s behavior.Konfetti manages your app’s configuration settings through lazy evaluation: It only calls and configures what your app needs and when it needs it.Key benefits:Configurable lazy evaluation- You can choose the moment when Konfetti will evaluate your the configuration of your app.Faster & simpler test runs- No need for evaluating the configuration of the whole project if it’s not used.Faster and flexible testing- Isolating small parts of your application no longer requires you to perform a complete setup for each test.Integration with popular Web Application Frameworks- Konfetti can seamlessly work with Django, Flask, and Celery.The interface design and features are heavily inspired bydecouple,Django,envparseanddynaconf.QuickstartBefore Konfetti can perform its tasks, you’ll need to create a settings module and then tell Konfetti the location of this module.1. Creating the Settings ModulePlease find the application settings, for your production, local, or other environments, using the following path:app_name/settings/production.pyNext, please review the below code block and copy the relevant parts in your settings file.> :warning:Variables need to be named with all uppercase letters, other variables will be ignored> :warning:If your app requires Vault access, then you’ll need to specify `VAULT_ADDR` and `VAULT_TOKEN` in the settings module# app_name/settings/production.pyfromkonfettiimportenv,vaultVAULT_ADDR=env("VAULT_ADDR")VAULT_TOKEN=env("VAULT_TOKEN")DEBUG=env("DEBUG",default=False)DATABASE_URI=vault("path/to/db")Apart from the import statementfrom konfetti import env, vault, you can remove the settings for the features that you don’t use.If, for instance, you don’t use a database, then you can remove theDATABASE_URIvariable. Depending on your settings, it might also be calledDB_URI, or similar.Furthermore, you can removeVAULT_ADDRandVAULT_TOKENif your app doesn’t require secrets.2. Configuring the Access Point# app_name/settings/__init__.pyfromkonfettiimportKonfig,AsyncVaultBackendconfig=Konfig(vault_backend=AsyncVaultBackend("/secret/team"))In your app’s environment variables, please add the KONFETTI_SETTINGS variable with the path to your settings module.  In the case of the code block above, it would be:export KONFETTI_SETTINGS=app_name.settings.productionAlternatively the access point could be initiated from an object, importable string, mapping or a JSON file:ObjectclassTestSettings:VALUE="secret"config=Konfig.from_object(TestSettings,...)Importable stringconfig=Konfig.from_object("path.to.settings",...)# If the config is in the same moduleSECRET=vault("/path/to")["secret"]config=Konfig.from_object(__name__,...)Mappingconfig=Konfig.from_mapping({"SECRET":42},...)JSONconfig=Konfig.from_json("/path/to.json")UsageThe settings module/class with configuration options shouldn’t be
accessed directly, because the aforementioned features are implemented
in the access point level.fromapp_name.settingsimportconfigasyncdefsomething():awaitconfig.DATABASE_URI# asynchronously taken from Vaultdebug=config.DEBUG# Usual sync accessDocumentationFor full documentation, please seehttps://konfetti.readthedocs.io/en/latest/Or you can look at thedocs/directory in the repository.Python supportKonfetti supports Python 2.7, 3.5, 3.6, 3.7 and 3.8LicenseThe code in this project is licensed underMIT license. By contributing tokonfetti, you agree that your contributions will be licensed under its MIT license.