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=Falsecast_to=str: fill in desired datatype. special case bool: 'True'/'true' will be True. 'False'/'false' will be Falsegetenv=True: you want to fall back to envvar. can be switched of via getenv=Falsedefault=Nonesafe=True: returns None if name not found or cast fails. If you want exceptions: safe=Falsesecrets_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
2.0.0 - 2023-07-23
- Changed: Use canonical
/run/secretsdirectory to read secrets from (changed from/var/run/secrets) (PR #4) (Thanks @ThorpeJosh)
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
Metadata
Release files for get-docker-secret 2.0.0
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 |
|---|---|---|---|---|
| get-docker-secret-2.0.0.tar.gz | 3.6 kB | Without provenance | Details for get-docker-secret-2.0.0.tar.gz |
Release files / get-docker-secret-2.0.0.tar.gz
| Download URL | get-docker-secret-2.0.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b39eab1caa69b4f7863fd3d9b419e0435c25f4747a1847de5a08161fe8d3410
|
|
BLAKE2b-256 checksum How to use checksums |
53108586b943cf23d3a620e546a2a126a79507378263890275e6c2fe8220a100
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for get-docker-secret 2.0.0
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.