Skip to main content

Load configurations from yaml files with automatic environment variable substitution

Project description

Envawareconfig

Load configurations from yaml files with automatic environment variable substitution.

Installation

with pip:

pip install envawareconfig

with poetry:

poetry add envawareconfig

QuickStart

Suppose you have a configuration file like this:

# test-config.yaml
database:
  name: my-database
  user: "${DB_USER:admin}"
  password: "${DB_PASSWORD}"

and that you have set the environment variable DB_PASSWORD to my-secret-password while DB_USER has been left unset.

then running the following code:

# main.py

from envawareconfig import load_config

config = load_config("tests/test-config.yaml")

would result in:

config = {
    "database": {
        "name": "my-database",
        "user": "admin",
        "password": "my-secret-password"
    }
}

Notice that ${DB_PASSWORD} has been expanded and ${DB_USER:admin} used the default value.

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

envawareconfig-0.2.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

envawareconfig-0.2.1-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

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