Skip to main content

A utility tool to create .env files

Project description

A utility tool to create .env files

wemake.services Build Status Coverage Python Version Docs wemake-python-styleguide

dump-env takes an .env.template file and some optional environmental variables to create a new .env file from these two sources. No external dependencies are used.

Why?

Why do we need such a tool? Well, this tool is very helpful when your CI is building docker (or other) images. Previously we had some complex logic of encrypting and decrypting files, importing secret keys and so on. Now we can just create secret variables for our CI, add some prefix to it, and use dump-env to make our life easier.

Installation

$ pip install dump-env

Quickstart

This quick demo will demonstrate the main and the only purpose of dump-env:

$ dump-env --template=.env.template --prefix='SECRET_ENV_' > .env

This command will:

  1. take .env.template
  2. parse its keys and values
  3. read and all the variables from the environment starting with SECRET_ENV_
  4. remove this prefix
  5. mix it all together, environment vars may override ones from the template
  6. sort keys in alphabetic order
  7. dump all the keys and values into the .env file

Advanced Usage

$ dump-env -t .env.template -p 'SECRET_ENV_' -p 'ANOTHER_SECRET_ENV_' > .env

This command will do pretty much the same thing as with one prefix. But, it will replace multiple prefixes. Further prefixes always replace previous ones if they are the same. For example:

$ export SECRET_TOKEN='very secret string'
$ export SECRET_ANSWER='13'
$ export ANOTHER_SECRET_ENV_ANSWER='42'
$ export ANOTHER_SECRET_ENV_VALUE='0'
$ dump-env -p SECRET_ -p ANOTHER_SECRET_ENV_
ANSWER=42
TOKEN=very secret string
VALUE=0

Creating secret variables in some CIs

Real-world usages

Projects that use this tool in production:

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

dump-env-1.0.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

dump_env-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file dump-env-1.0.0.tar.gz.

File metadata

  • Download URL: dump-env-1.0.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.7.3 Darwin/18.2.0

File hashes

Hashes for dump-env-1.0.0.tar.gz
Algorithm Hash digest
SHA256 76c4deac11d06bd4678bd5a6d7a7c297e00caa706b164c7dc0f06ec2ef4669d7
MD5 2737a6e85e7468ae99b1b7e7116b11f6
BLAKE2b-256 968f7b811bafd8d35bbf7e7cf3c87767d6f15a1ddc6f6ab5fc3a5cc852aae5c6

See more details on using hashes here.

File details

Details for the file dump_env-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dump_env-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.11 CPython/3.7.3 Darwin/18.2.0

File hashes

Hashes for dump_env-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f929600c1497cb029edfa955ddfd84e5b7f18cadbbd77396aa2339685c7b4ec3
MD5 3330e0cc2e392bc6e12ce945e9980579
BLAKE2b-256 cb2a3ae77a78cc11b3d868e35bd4495b6081ff1cfd09ed568c6f239019360b5c

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