Skip to main content

A utility for managing .env files using Google Cloud Secret Manager

Project description

grasp-env-handler

A utility for managing .env files using Google Cloud Secret Manager for Grasp teams.

Overview

This tool helps Grasp teams securely manage their .env files by storing them in Google Cloud Secret Manager. It uses your GitHub repository name to organize secrets logically and provides simple commands to push and pull environment variables across your team.

Features

  • Pull .env files from Secret Manager with grasp env pull
  • Push .env files to Secret Manager with grasp env push
  • Support for recursive operations with the -r flag
  • Ignore specific .env files with .envignore

Installation

Install the package directly from PyPI using pip or uv:

pip install grasp-env-handler
uv pip install grasp-env-handler

Development Installation

For development:

# Clone the repository
git clone https://github.com/username/grasp-env-handler.git
cd grasp-env-handler

# With pip
pip install -e .

# With uv
uv pip install -e .

Requirements

  • Python 3.8+
  • Google Cloud SDK installed and configured
  • Git repository connected to GitHub

GCP Setup

Before using this tool, make sure:

  1. You have the Google Cloud SDK installed
  2. You are authenticated with GCP: gcloud auth login
  3. You have set a default project: gcloud config set project YOUR-PROJECT-ID
  4. The Secret Manager API is enabled in your project: gcloud services enable secretmanager.googleapis.com
  5. You have the necessary permissions to create and access secrets

Usage

# Pull all .env files in current directory
grasp env pull

# Pull .env files recursively from all subdirectories
grasp env pull -r

# Push all .env files in current directory (asks for confirmation before overwriting)
grasp env push

# Push .env files recursively from all subdirectories
grasp env push -r

# Push .env files, overwriting existing secrets without confirmation
grasp env push --force
# or
grasp env push -f

.envignore

Create a .envignore file in your repository to exclude specific .env files:

# Example .envignore
path/to/secret.env
*.test.env

See .envignore.example for more examples.

Publishing to PyPI (for maintainers)

To publish a new version of this package to PyPI:

  1. Increment the version number in pyproject.toml (e.g., from 0.1.0 to 0.1.1).

  2. Build the package:

    uv build
    

    This will create distribution files (a .tar.gz and a .whl) in the dist/ directory.

  3. Publish to PyPI: You will need an API token from PyPI. Generate one from your PyPI account settings if you don't have one. Then, run the following command, replacing YOUR_PYPI_API_TOKEN with your actual token:

    uv publish dist/* -t YOUR_PYPI_API_TOKEN
    

    Alternatively, you can set the UV_USERNAME=__token__ and UV_PASSWORD=YOUR_PYPI_API_TOKEN environment variables and then run uv publish dist/*.

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

grasp_env_handler-0.1.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

grasp_env_handler-0.1.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file grasp_env_handler-0.1.3.tar.gz.

File metadata

  • Download URL: grasp_env_handler-0.1.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.1

File hashes

Hashes for grasp_env_handler-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c1bdf1d133ed992c58efb2ac37913e3d9de00e7658ae3b1425441c3aed91793c
MD5 0fac4abbe09f759707bc4ba01b23ac56
BLAKE2b-256 5b2f64b32a2693373304059a4c6d10c27ffca83732cf2741081f500cddfeb90e

See more details on using hashes here.

File details

Details for the file grasp_env_handler-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for grasp_env_handler-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0b551ab459c63e79a61c011ae81467424eedf1f0a14e4c74f64fe6a332074c1e
MD5 c361cf5c50321ed6d3794949884dfc0a
BLAKE2b-256 37b4c6efa66f40233e4332dfb666e69ce793836c301ead7196cf53375a4978c6

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