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
  • getenv=True: you want to fall back to envvar. can be switched of via getenv=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

Changelog

1.0.2 - 2021-03-19

  • Fixed: Only strip trailing newlines from secrets file

1.0.1 - 2019-12-07

  • Fixed: Strip values read from file.

1.0.0 - 2018-01-30

  • Initial publish

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.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distributions

get_docker_secret-1.0.2-py3.9.egg (3.9 kB view details)

Uploaded Source

get_docker_secret-1.0.2-py3.8.egg (3.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: get-docker-secret-1.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7

File hashes

Hashes for get-docker-secret-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7c37ae90ff9c01878ecde91e8545813e31ed1b2bcb859a050edbfbfeb2023438
MD5 b93a5d5166dfd0c24bd7cea1fbeedc9f
BLAKE2b-256 a6f0af549ef2b12768025d6fb1be792d45e387fb835e3ac3d66b9ff767ed8428

See more details on using hashes here.

File details

Details for the file get_docker_secret-1.0.2-py3.9.egg.

File metadata

  • Download URL: get_docker_secret-1.0.2-py3.9.egg
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.0.1 pkginfo/1.4.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.7

File hashes

Hashes for get_docker_secret-1.0.2-py3.9.egg
Algorithm Hash digest
SHA256 cc6809c56a6c6f8171f60735c6d6b2f701b2f7d38a9a0b2eb153602f6131189a
MD5 1b1e191640ab58f118777f58f50f628f
BLAKE2b-256 f4d883a81ab65dc994f542e91676c2a87055e4c87209d9d1f73f7666c322c8af

See more details on using hashes here.

File details

Details for the file get_docker_secret-1.0.2-py3.8.egg.

File metadata

  • Download URL: get_docker_secret-1.0.2-py3.8.egg
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.6

File hashes

Hashes for get_docker_secret-1.0.2-py3.8.egg
Algorithm Hash digest
SHA256 c1b8e6e70ca84082b5b3feb3a76114d452f06351083c725f3002dd8da7f546c1
MD5 e345cbcb37ccda44e39691147f6c819b
BLAKE2b-256 dcb519cfa48dfa5699432f9d8f1b2d809166799597b513d194bdf000addeffc2

See more details on using hashes here.

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