Skip to main content

Pre-flight environment checks. Like Pydantic, but for your infra.

Project description

envguard

Pre-flight environment validation for Python projects.
Checks env vars, TCP ports, HTTP endpoints and files — before you deploy.

pip install envguard

─────────────── pandora-ai — pre-flight check ───────────────

  ENV VARS
  ✓  OPENAI_API_KEY       present
  ✓  REDIS_URL            present
  ✗  DATABASE_URL         missing

  TCP PORTS
  ✓  Redis                localhost:6379 reachable
  ✗  PostgreSQL           localhost:5432 connection refused

  HTTP ENDPOINTS
  ✓  OpenAI reachable     200 OK
  ✗  App health           connection refused

─────────────────────────────────────────────────────────────
  3 checks failed, 2 passed, 5 total
  Run with --hints for suggestions.

Contents


Installation

pip install envguard

Requires Python 3.9+.

Quickstart

# generate a starter envguard.yaml
envguard init

# run checks
envguard check

# show fix suggestions for failures
envguard check --hints

envguard walks up the directory tree looking for envguard.yaml automatically.
If a .env file exists in the current directory, it's loaded before checks run.

Config reference

name: my-app

env_vars:
  - key: OPENAI_API_KEY
    required: true
    validate: starts_with:sk-

  - key: DATABASE_URL
    required: true
    validate: contains:postgresql

  - key: DEBUG
    required: false        # skipped if missing, won't fail

tcp_ports:
  - host: localhost
    port: 5432
    label: PostgreSQL      # shown in output instead of host:port
    timeout: 3.0           # seconds, default 3.0

http_endpoints:
  - url: http://localhost:8000/health
    expect_status: 200
    timeout: 5.0

files:
  - path: .env
    type: file
  - path: ./data
    type: directory

validate rules for env vars

Rule Example Description
starts_with:<s> starts_with:sk- value must start with s
ends_with:<s> ends_with:.local value must end with s
contains:<s> contains:postgresql value must contain s
min_length:<n> min_length:32 value length must be ≥ n

CLI

envguard check                     run all checks
envguard check --hints             show hints for failed checks
envguard check -c path/to/file     use a specific config file
envguard init                      generate a starter config
envguard init --name my-app        set project name

Exit code: 0 if all checks pass, 1 if any fail.

Makefile / CI

deploy:
	envguard check || exit 1
	docker compose up -d
# .github/workflows/deploy.yml
- name: Pre-flight check
  run: envguard check

Contributing

Issues and pull requests are welcome.

Reporting a bug

Before opening an issue, check existing issues to avoid duplicates.

A good bug report includes:

  • envguard version (pip show envguard)
  • Python version and OS
  • your envguard.yaml (redact secrets)
  • full output with envguard check
  • what you expected to happen

Suggesting a feature

Open an issue with the enhancement label.
Describe the use case, not just the feature — it helps figure out the right solution.

Sending a pull request

git clone https://github.com/yourusername/envguard
cd envguard
pip install -e ".[dev]"

# make your changes
pytest

A few ground rules:

  • one PR per feature or fix
  • add a test for new behavior
  • don't bump the version — that happens on release
  • if you're fixing a bug, reference the issue number in the PR description

Not sure if a change is in scope? Open an issue first and ask.

Adding a new check type

Check implementations live in envguard/checks/.
Each check is a function that takes a spec dataclass and returns a CheckResult.
See envguard/checks/tcp.py for a minimal example.

To add a new check type end-to-end:

  1. add a dataclass to models.py
  2. implement the check in checks/your_check.py
  3. wire it into runner.py and loader.py
  4. add it to the reporter sections in reporter.py
  5. write tests in tests/

Known issues

  • HTTP redirects — followed by default, no config option to disable yet
  • Windows — not tested; path handling in file checks may have edge cases
  • min_length with non-integer arg — fails silently instead of raising a clear error

If you hit something not listed here, please open an issue.


License

MIT

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

env_guard_checker-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

env_guard_checker-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file env_guard_checker-0.1.1.tar.gz.

File metadata

  • Download URL: env_guard_checker-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for env_guard_checker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 19a6ec653cb20580fd09a4ba2c9c707d0ffea6d6aa87e1b6456c1c20d81ce3e2
MD5 c75a2df7b467858d99bd02ab9215683d
BLAKE2b-256 74bc377c97435edac9d91af2e1d6493958fe0b3adfc2c754b806a29b1a4705fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for env_guard_checker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd7d3a20698a4808c6f7356e25533c5b05f41d1d30143e3780d81f3fa7ac4cd3
MD5 9d85f6b13f04a92997cb8a9b6e51db80
BLAKE2b-256 365c1288698d533642dc799e6c37329e2224b4656fd82a8afbf4aaf5356e93ef

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