Skip to main content

Configuration File

envcheck uses a YAML configuration file to define environment validation rules. The configuration file specifies which tools, environment variables, ports, files, and network endpoints should be checked.

File Location

envcheck automatically searches for configuration files in the following order:
  1. .envcheck.yaml
  2. .envcheck.yml
  3. envcheck.yaml
  4. envcheck.yml
The first file found in the current directory will be used.
If no configuration file is found, you can create one by running envcheck init or by creating a .envcheck.yaml file manually.

Configuration Structure

A configuration file consists of a required version field and optional validator sections:
version: "1"

tools:
  - name: node
    version: ">=18.0.0"
    required: true

env_vars:
  - name: DATABASE_URL
    required: true

ports:
  - 3000
  - 5432

files:
  - path: .env
    required: true

network:
  - url: https://api.example.com/health
    status_code: 200

Version Field

version
string
required
The configuration file format version. Currently, only "1" is supported.
version: "1"
The version field is required. Omitting it will cause the configuration file to fail validation.

Validator Sections

All validator sections are optional and default to empty arrays if not specified:
tools
array
default:"[]"
Tool validation checks. See Tool Validation for details.
env_vars
array
default:"[]"
Environment variable checks. See Environment Variables for details.
ports
array
default:"[]"
Port availability checks. See Port Checks for details.
files
array
default:"[]"
File and directory validation. See File Validation for details.
network
array
default:"[]"
Network connectivity checks. See Network Checks for details.

Complete Example

Here’s a complete configuration file for a Node.js project:
version: "1"

tools:
  - name: node
    version: ">=18.0.0"
    required: true
  - name: npm
    version: ">=9.0.0"
    required: true
  - name: git
    required: true

env_vars:
  - name: NODE_ENV
    required: false
  - name: DATABASE_URL
    required: true

ports:
  - 3000
  - 5432

files:
  - path: .env
    required: true
  - path: package.json
    required: true

Loading Configuration

The configuration file is loaded from src/config.rs:66 using the Config::load() method, which reads and parses the YAML file. The Config::find_config() method (src/config.rs:76) automatically searches for configuration files in the standard locations.