Skip to main content

Utility function to fetch docker secrets/envvars.

Project description

version license pyversions pipeline status coverage

get-docker-secret

Utility function to fetch docker secrets/envvars.

For config values (flask projects) i like to fetch docker secrets and fall back to environment variables for development. This module provides a function to make this a one-liner: use docker secret -> fall back to envvar -> fall back to default value.

The function also provides the possibility to automatically cast the value or specify a custom directory for secrets.

Following assumptions are being made (params): * autocast_name=True: secrets are lower-case, envvars upper-case. automatic conversion of name can be switched off via autocast_name=False * cast_to=str: fill in desired datatype. special case bool: ‘True’/’true’ will be True. ‘False’/’false’ will be False * envvar=True: you want to fall back to envvar. can be switched of via envvar=False * default=None * safe=True: returns None if name not found or cast fails. If you want exceptions: safe=False * secrets_dir=/var/run/secrets

Usage

from get_docker_secret import get_docker_secret

value = get_docker_secret('secret_key', default='very_secret')

Testing

python setup.py test

not tested under windows

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

get-docker-secret-1.0.0.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file get-docker-secret-1.0.0.tar.gz.

File metadata

File hashes

Hashes for get-docker-secret-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5f86039da59e9124ba4f9cb295851f91b136e6d044ae468d324aab689137f69c
MD5 e85f23521dfc08613e60aec038f6ca3a
BLAKE2b-256 af993d70dc6eadbac1f5bc2a20702774716d86e4878852c32f39ab0fc204afc0

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