Manage Conf
Description
Builds a config object based on environment variables, settings files and (optional) parameters stored in AWS System Manager Parameter Store.
The config object merges in config, overriding any previous key/value pairs, in the following order:
- ENV
- default config: default.json
- stage config: {stage}.json
- remote config: remote_settings (AWS param store)
Available to download as a package on PyPi.
Settings Files
Set an environment variable with the key name project_config_dir. It is important this is set before the package is imported. The value of project_config_dir should be the location of your /settings folder.
Set-up your settings folder, adding in configuration to the appropriate file.
.
├── settings <-- Settings folder
│ ├── default.json <-- default configuration
│ ├── {stage}.json <-- stage specific configuration e.g. `local`
│ └── {stage}.json <-- stage specific configuration e.g. `dev`
Example configuration:
default.json
{
"project_name": "example-project",
"DEBUG": false
}
local.json
{
"DEBUG": true,
"use_remote_settings": false
}
Local config object:
{
"project_name": "example-project",
"DEBUG": True,
"use_remote_settings": False
}
dev.json
{
"use_remote_settings": true
}
Dev config object:
{
"project_name": "example-project",
"DEBUG": True,
"use_remote_settings": True
# and any remote settings from AWS param store
}
AWS Param Store
Project config
Add parameters in your AWS account with paths that match this pattern:
/{project_name}/{stage}/
If you set "use_remote_settings": true in a remote {stage}.json config file, the package will attempt to fetch the parameters from the store that have the specified base path. Using the example configuration above, the path would be:
/example-project/dev/
Global service directory config
Add parameters in your AWS account with paths that match this pattern:
/global/{stage}/service_directory/
Set "global_service_directory": true in a remote {stage}.json config file.
Global service directory config for the {stage} will be merged in.
Usage
Make sure project_config_dir is set before importing the library.
from manageconf import Config, get_config
SECRET_KEY = get_config("SECRET_KEY")
DEBUG = get_config("DEBUG", True)
# default values are an optional second arg and will
# be used if the param cannot be found in the config object
Development
Install
Requires Poetry.
# create a Python3 virtual environment
virtualenv -p python3 env
# activate the virtual env
source env/bin/activate
# install requirements
poetry install
Tests
# run tests
pytest -vv
# coverage report in the Terminal
pytest --cov=manageconf tests/
# coverage report in HTML
pytest --cov-report html --cov=manageconf tests/
Metadata
Release files for manageconf 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| manageconf-1.1.1.tar.gz | 5.0 kB | Without provenance | Details for manageconf-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| manageconf-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for manageconf-1.1.1-py3-none-any.whl |
Total release size: 14.4 kB
Release files / manageconf-1.1.1.tar.gz
| Download URL | manageconf-1.1.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4ff2feeb79a423aaa60dd770173373227e55c92e91ccc839b131c5486136101
|
|
BLAKE2b-256 checksum How to use checksums |
f6be237c3c87cfe29142f9afd4a7b1a4cf3e2597b5491ef88798d4e37b262807
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.7.3 Darwin/18.5.0
|
Release files / manageconf-1.1.1-py3-none-any.whl
| Download URL | manageconf-1.1.1-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2315017e0ede3cb65950bafacce795ce183b99c752ff8210eced8fb6e1fac377
|
|
BLAKE2b-256 checksum How to use checksums |
f65e1ef8180f07487ba75f71e2fc40b13920097fcbe82386ed794b26b1600dd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.7.3 Darwin/18.5.0
|
Security for manageconf 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.