Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

envguard

A tiny CLI that checks your .env against .env.example and fails loudly when they drift apart. No dependencies, one job, done well.

Маленький CLI, который сверяет твой .env с .env.example и громко падает, когда они разошлись. Без зависимостей, одна задача — сделана хорошо.

Python License Dependencies CI

envguard catching a missing, empty and extra variable

The problem

You add SECRET_KEY to .env.example, deploy, and the app crashes because the server's .env never got it. Or a teammate pulls, copies the example, and misses a new variable. envguard catches this in one command — locally or in CI.

Install

pip install git+https://github.com/dimaad5017-dotcom/envguard
# or, from a clone:
pip install -e .

Usage

envguard                       # compares ./.env against ./.env.example
envguard -e .env.prod -x .env.example

Example output when something is off:

Missing keys (in example, not in your .env):
  - REDIS_URL
Empty values (set but blank):
  - SECRET_KEY
Extra keys (in your .env, not in example):
  - LEGACY_TOKEN

Exit codes:

Code Meaning
0 everything matches
1 mismatch found
2 a file was not found

Options

Flag Description
-e, --env path to the env file (default .env)
-x, --example path to the example file (default .env.example)
--allow-extra don't fail on keys that exist only in .env
--allow-empty don't fail on keys with blank values
--no-color plain output

Use in CI

- run: pip install git+https://github.com/dimaad5017-dotcom/envguard
- run: envguard -e .env.ci -x .env.example

A non-zero exit fails the job, so a forgotten variable blocks the merge instead of the deploy.

Use as a library

from envguard import parse_dotenv, check

example = parse_dotenv(open(".env.example").read())
actual = parse_dotenv(open(".env").read())
report = check(example, actual)
if not report.ok:
    print(report.missing, report.empty, report.extra)

Зачем (RU)

Добавил переменную в .env.example, выкатил — а на сервере её нет, приложение падает. Или коллега скопировал пример и пропустил новую переменную. envguard ловит это одной командой: локально или в CI. Ненулевой код выхода роняет пайплайн до деплоя, а не после.

License

MIT

About

A tiny dependency-free CLI that checks your .env against .env.example and fails on missing, empty or extra variables.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages