Skip to main content

Python package to convert Kubernetes secrets into .env files with key-value pairs for easier local development.

Project description

secrettoenv

secrettoenv is a Python command-line tool that converts Kubernetes secrets into .env files for easier local development. It supports secret retrieval from both Kubernetes clusters and local files in JSON or YAML format.

Features

  • Converts Kubernetes secrets to .env files with key-value pairs.
  • Supports secret files in JSON or YAML format.
  • Can fetch secrets directly from a Kubernetes namespace using your local kubectl configuration.
  • Customizable output file name and location for the generated .env file.

Installation

You can install the package directly from PyPI using pip:

pip install secrettoenv

Requirements

  • Python version: 3.9 or higher
  • Dependencies: The necessary dependencies (e.g., click, kubernetes) are automatically installed with pip.

Usage

Once installed, you can use the secrettoenv command to convert a Kubernetes secret or a local file to an .env file.

Basic Command:

secrettoenv --namespace <namespace> --secret-name <secret_name> --output-file <output_file>
secrettoenv --file <file_path> --output-file <output_file>

Options:

  • --namespace: Specifies the Kubernetes namespace where the secret resides. Default is default.
  • --secret-name: The name of the Kubernetes secret.
  • --file: The file containing Kubernetes secrets (supports JSON and YAML formats).
  • --output-file: The output .env file name. Default is env.
  • --kube-config: The path to your Kubernetes configuration file. Default is ~/.kube/config.

Example:

secrettoenv --namespace my-namespace --secret-name my-secret --output-file my-secrets.env
secrettoenv --file my_secret.json --output-file my-secrets.env

This command will generate a file my-secrets.env with secrets in key-value format from the specified Kubernetes secret.

Development Setup

If you want to contribute or modify the code, you can set up the project locally using Poetry.

Steps:

  1. Clone the repository.

  2. Install dependencies with Poetry:

    poetry install
    
  3. Run the project using:

    poetry run secrettoenv --namespace <namespace> --secret-name <secret_name> --output-file <output_file>
    

License

This project is licensed under the MIT License. See the LICENSE file for details.

Future Enhancements

  • Add support for additional secret formats.
  • Provide more advanced error handling and validation.

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

secrettoenv-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secrettoenv-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file secrettoenv-0.1.0.tar.gz.

File metadata

  • Download URL: secrettoenv-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for secrettoenv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46bda72bcbc9b1775b8d038acac98ef0e29faadf7fb5ec0e39fb4b01bab470a4
MD5 caabba792874d97f8df7ad7b8c778ddb
BLAKE2b-256 20e1a030ec9ba9ac7009bc837eb981dd84540b80ca3f35bf319f58e8761be5de

See more details on using hashes here.

File details

Details for the file secrettoenv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: secrettoenv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for secrettoenv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1317237c472d4d02eae63a4f0bd0bbc0f41794ed9ed062739b8c769c6e6987e2
MD5 cfa895f08292e6d67dfe272d0ed40312
BLAKE2b-256 5ffb972df01abf4f5c968ececc7bb216b3c28b4dd3c22fca0fd47ce6d506271c

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