| Crates.io | secenv |
| lib.rs | secenv |
| version | 0.1.0 |
| created_at | 2025-09-01 01:24:59.390932+00 |
| updated_at | 2025-09-24 15:30:51.308856+00 |
| description | Secure environments. |
| homepage | https://github.com/cchexcode/secenv |
| repository | https://github.com/cchexcode/secenv |
| max_upload_size | |
| id | 1819018 |
| size | 108,241 |
Secure, profile-based environment variable management with HOCON configuration, optional PGP decryption, and GCP Secret Manager integration.
gcloudliteral, environment, file, gcp.plain, gcp.pgpgit clone https://github.com/cchexcode/secenv
cd secenv
cargo build --release
The binary will be at target/release/secenv.
secenv.conf (HOCON)version = "0.0.0" # Config version must be compatible with the CLI version
profiles.default.env {
# Optional regex patterns of variables to keep when executing a command
# If set, the child environment is cleared first, then only matching host vars are kept.
# If omitted, the full host environment is kept.
# keep = ["^PATH$", "^SHELL$", "^LC_.*"]
vars {
APP_NAME.literal = "myapp"
HOME_DIR.environment = "HOME"
CONFIG_JSON.file = "/etc/myapp/config.json"
# Retrieve a secret value directly from GCP Secret Manager (plain text)
DB_PASSWORD.gcp.plain.secret = "projects/123456789/secrets/db-password"
# Decrypt a PGP-encrypted value using a private key stored in GCP Secret Manager
# - secret: GCP secret holding the ASCII-armored private key
# - value.literal: ASCII-armored PGP message (or use value.base64)
SERVICE_TOKEN.gcp.pgp {
secret = "projects/123456789/secrets/pgp-private-key"
value.literal = """
-----BEGIN PGP MESSAGE-----
...
-----END PGP MESSAGE-----
"""
}
}
}
profiles.production.env.vars {
APP_NAME.literal = "myapp"
DB_PASSWORD.gcp.plain.secret = "projects/123456789/secrets/prod-db-password"
}
Notes:
version field is validated against the CLI version. The config must not be newer than the CLI, and major versions must match.gcp.pgp, the private key must be a valid ASCII‑armored OpenPGP private key stored in GCP Secret Manager.# Print key=value pairs for the default profile
secenv unlock
# Use a specific profile and config path
secenv unlock --config /path/to/secenv.conf --profile production
# Load into current shell (bash/zsh/fish)
eval "$(secenv unlock --profile production)"
To run a command with the variables set:
# Run a program inheriting host environment (default behavior)
secenv unlock --profile production -- env | sort
# With keep configured in the profile, only matching host vars are preserved
secenv unlock --profile production -- printenv | sort
# Execute a command
secenv unlock --profile production -- make deploy
Output format when printing:
APP_NAME=myapp
DB_PASSWORD=...
HOME_DIR=/Users/you
version = "<semver>"
profiles = { <name> = { env = { keep = [<regex>], vars = { ... } } } }
profiles.<profile>.env.keep = ["^PATH$", "^LC_.*"] # optional
profiles.<profile>.env.vars { # required
KEY.literal = "value"
KEY.environment = "ENV_NAME"
KEY.file = "/path/to/file"
# From GCP Secret Manager (plain)
KEY.gcp.plain.secret = "projects/<project>/secrets/<name>"
# Decrypt PGP with a private key retrieved from GCP Secret Manager
KEY.gcp.pgp.secret = "projects/<project>/secrets/<private-key>"
KEY.gcp.pgp.value.literal = "-----BEGIN PGP MESSAGE-----..."
# or
KEY.gcp.pgp.value.base64 = "<base64-encoded-ASCII-armored-message>"
}
Important:
gcp.pgp).Global options:
-e, --experimental – enable experimental featuresCommands:
Unlock values and optionally execute a command with the variables set.
secenv unlock [OPTIONS] [--] [COMMAND...]
Options:
-c, --config <path> Path to config (default: secenv.conf)
-p, --profile <name> Profile name (default: default)
Behavior:
COMMAND, prints KEY=VALUE lines to stdout.COMMAND, executes it with variables set. If env.keep is set in the profile, the child environment is cleared first and only host variables matching any regex in keep are preserved; otherwise, the full host environment is kept.Render the manual pages or markdown help.
secenv man --out <directory> --format <manpages|markdown>
Generate shell completion scripts.
secenv autocomplete --out <directory> --shell <bash|zsh|fish|elvish|powershell>
Initialize a new HOCON config file.
secenv init [--path <path>] [--force]
Notes:
--path (default: secenv.conf). You should edit it to add version, profiles, and vars as shown above.gcloud (gcloud auth login or service account with suitable permissions).projects/<project>/secrets/<name> (optional /versions/<version>; defaults to latest).profiles.<name> exists in the config.gcloud authentication, project, permissions, and secret name.For verbose logs:
RUST_LOG=debug secenv unlock
PRs are welcome!
git clone https://github.com/cchexcode/secenv
cd secenv
cargo build
cargo test
MIT – see LICENSE.