Skip to main content

Compare dotenv files and report configuration drift.

Project description

env-drift-report

Compare dotenv files and report configuration drift before missing keys reach a deploy, onboarding guide, or CI job.

Problem

.env.example files often drift away from real local or template configuration. A teammate adds STRIPE_WEBHOOK_SECRET to one file, leaves another template untouched, and the gap only appears after a failed setup. This CLI checks required keys, empty values, duplicate entries, malformed lines, and unexpected extras with output that works for humans or CI logs.

Install

pip install env-drift-report

For local development:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

CLI Usage

Compare .env against .env.example:

env-drift-report .env

Compare several files against a reference:

env-drift-report --reference .env.example .env .env.production.example

Emit JSON for scripts:

env-drift-report --reference .env.example --format json .env

Ignore target-only keys when local files are expected to contain private values:

env-drift-report --ignore-extra .env

Ignore commented KEY=value examples:

env-drift-report --ignore-commented .env

The command exits with:

  • 0 when every target file passes
  • 1 when drift is found
  • 2 when a file cannot be read

Python Usage

from env_drift_report import compare_env_files

report = compare_env_files(".env.example", ".env")

if not report.ok:
    print(report.missing)

Example Output

FAIL .env
Reference: .env.example
Missing:
  - REDIS_URL
Empty:
  - API_KEY (line 1)
Extra:
  - DEBUG_SQL
Duplicates:
  - .env:PORT (lines 2, 3)

Supported Dotenv Syntax

The parser intentionally supports the common subset used by templates:

  • KEY=value
  • export KEY=value
  • commented examples like # KEY=value
  • quoted values
  • inline comments after unquoted values

It does not evaluate shell expansion or source other files.

Development

Run tests:

PYTHONPATH=src python3 -m unittest discover -s tests

Build the package:

python3 -m build

Contributing

Issues and pull requests are welcome. Keep changes focused, include tests for behavior changes, and update the README when command behavior changes.

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_drift_report-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

env_drift_report-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: env_drift_report-0.1.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for env_drift_report-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7546a09a8d8bad0e66bc67ca9e2570bf42b11fa1bbf940c81b7a038d39554060
MD5 0597ae9f03fffce5e4dc4a8b5e987e47
BLAKE2b-256 6f189faec18e1cce141254b3a37c7bcbd3e90e1b6751acdf080547bc922aca83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for env_drift_report-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bec0118224c6d4b45cd6047df0d2810aee4585388dee53b77fd3dcce59026424
MD5 9a30c3a73fd69bbdd7fac0d6b8436147
BLAKE2b-256 3db6d286b4c35c9aa3af5e132c87bb40a8cf81f1fb7e9be70f71b2a42c7bd6cd

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