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
.envfiles with key-value pairs. - Supports secret files in JSON or YAML format.
- Can fetch secrets directly from a Kubernetes namespace using your local
kubectlconfiguration. - Customizable output file name and location for the generated
.envfile.
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 withpip.
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 isdefault.--secret-name: The name of the Kubernetes secret.--file: The file containing Kubernetes secrets (supports JSON and YAML formats).--output-file: The output.envfile name. Default isenv.--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:
-
Clone the repository.
-
Install dependencies with Poetry:
poetry install -
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46bda72bcbc9b1775b8d038acac98ef0e29faadf7fb5ec0e39fb4b01bab470a4
|
|
| MD5 |
caabba792874d97f8df7ad7b8c778ddb
|
|
| BLAKE2b-256 |
20e1a030ec9ba9ac7009bc837eb981dd84540b80ca3f35bf319f58e8761be5de
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1317237c472d4d02eae63a4f0bd0bbc0f41794ed9ed062739b8c769c6e6987e2
|
|
| MD5 |
cfa895f08292e6d67dfe272d0ed40312
|
|
| BLAKE2b-256 |
5ffb972df01abf4f5c968ececc7bb216b3c28b4dd3c22fca0fd47ce6d506271c
|