Skip to main content

Configuration and Secrets for Python applications

Project description

Configure-Tron

https://img.shields.io/pypi/v/configuretron.svg https://img.shields.io/travis/channelcat/configuretron.svg Documentation Status Updates

Configuretron enables type hinted configuration files and secrets for python. Easily add secrets to your configuration that are encryptable from clients and decryptable from trusted developers and running services.

Features

  • Type-hinted configuration

  • Simple, readable YAML configs

  • Config in source control

  • Secrets safely in source control

  • Easily swap environments

  • Control who can encrypt and decrypt

Installation

$ python -m pip install configuretron

Usage

config.yml

config:
    api_url: https://apitopia.com/api/v1
    api_timeout: 20

config.py

@dataclass
class Config:
    api_url: str
    api_timeout: int = 30

config = configuretron.from_yaml(Config, "config.yml")

Adding Secrets

Adding encryption just takes a few console commands

$ python -m configuretron --yaml=config.yml setup_encryption

Copy the generated base64 private key into an environment variable (in this example, PRIVATE_KEY)

Encrypt and variables in the config (in this example, api_token):

$ python -m configuretron --yaml=config.yml encrypt --key api_token

Then pass the key to the config

private_key = configuretron.env_base64_value('PRIVATE_KEY')
config = configuretron.from_yaml(Config, "config.yml", private_key=private_key)

Environmental overrides

To override values per-environment, add them into the config like so:

config:
    api_url: http://localhost:8080/api/v1
    api_timeout: 20
env:
    prod:
        config:
            api_url: https://apitopia.com/api/v1

Then just pass env when initializing the configuration:

config = configuretron.from_yaml(Config, "config.yml", env="prod")

TODO Features

  • Config heirarchy

  • Type validation

  • Multiple layered configs

History

0.1.0 (2022-12-22)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

configuretron-0.2.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configuretron-0.2.0-py2.py3-none-any.whl (7.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file configuretron-0.2.0.tar.gz.

File metadata

  • Download URL: configuretron-0.2.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for configuretron-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b5450fa893b1c8c732d84b59a65a48cb3f0595df6b25b0e98b40b9a509bb917e
MD5 2af12e89388eecbca3955e137201f02e
BLAKE2b-256 84a4e504d1c3af4a95bacc20cc53a41ab6981cb0fad4fd8c2fa7b2875e9ceea2

See more details on using hashes here.

File details

Details for the file configuretron-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for configuretron-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c3a8ee6bd151709c6ddc4c7135d2b0974084c6f40050d5db873f189e2523b155
MD5 8a7eaad51bd49632ea3aeed5676b24f9
BLAKE2b-256 95a54ddb2d9f57ce6a7e7783d8ce3b8dd1945b6955d2caeefea3f4e062febfd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page