Skip to main content

A utility tool to create .env files

Project description

A utility tool to create ``.env`` files
---------------------------------------

.. image:: https://travis-ci.org/sobolevn/dump-env.svg?branch=master
:target: https://travis-ci.org/sobolevn/dump-env

.. image:: https://coveralls.io/repos/github/sobolevn/dump-env/badge.svg?branch=master
:target: https://coveralls.io/github/sobolevn/dump-env?branch=master

.. image:: https://badge.fury.io/py/dump-env.svg
:target: http://badge.fury.io/py/dump-env

.. image:: https://img.shields.io/pypi/pyversions/dump-env.svg
:target: https://pypi-hypernode.com/pypi/dump-env

.. image:: https://readthedocs.org/projects/dump-env/badge/?version=latest
:target: http://dump-env.readthedocs.io/en/latest/?badge=latest

``dump-env`` takes an ``.env.template`` file and some optional environmental variables to create a new ``.env`` file from these two sources.

Quickstart
~~~~~~~~~~

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

.. code:: bash

$ 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, where environment variables could override ones with the same name from the template
6. sort keys in alphabetic order
7. dump all the keys and values into the ``.env`` file

Installation
~~~~~~~~~~~~

.. code:: bash

$ pip install dump-env

Why?
~~~~

Why do we need such a tool? Well, this tool is very helpful when your CI is building ``docker`` (or other) images.
`Previously <https://github.com/wemake-services/wemake-django-template/blob/6a7ab060e8435fd855cd806706c5d1b5a9e76d12/%7B%7Bcookiecutter.project_name%7D%7D/.gitlab-ci.yml#L25>`_ 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.

Creating secret variables in some CIs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``travis``: `docs <https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml>`_
- ``gitlab-ci``: `docs <https://docs.gitlab.com/ce/ci/variables/README.html#secret-variables>`_


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

Uploaded Source

Built Distributions

dump_env-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

dump_env-0.1.1-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: dump-env-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for dump-env-0.1.1.tar.gz
Algorithm Hash digest
SHA256 afc11fd3c2af0dd74014ebc559571e434a00535eb2131afd15b7059117d562e4
MD5 5baf506d416b8778a294bfd3bb6a639a
BLAKE2b-256 cc1b5710919feebb6d646b2eea19a5be447e1d6f1945f4ed9077341ac1695433

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dump_env-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17ef8404ead498a895d8a374fa02e23b8a0f8eb31eb329ee6c39ef6b49880009
MD5 5f619b5d911343e4d3cac4a332d195bb
BLAKE2b-256 f451c8ea987abf4e3b224efed7fb3fecbc8a40820df3abb0e1ae20a71f3f3920

See more details on using hashes here.

File details

Details for the file dump_env-0.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for dump_env-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 70d4c4f2cee3bfe5569665ef57c2cd8fe6e3544d4d3d375c3757c335f49d6491
MD5 ce59a7d257075d751e859d6d752e8b8a
BLAKE2b-256 8fb49a9b4c372e73ae9de90b2aea99031a99f8f042d3622e0c6eae051af26a04

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