Skip to content

Conversation

bdmorin
Copy link

@bdmorin bdmorin commented Aug 21, 2025

Summary

This PR adds command-line configuration validation functionality to Gatus, addressing a common need for validating configurations in CI/CD pipelines and deployment scripts without requiring full application startup.

Changes

  • Added --validate flag: Validates configuration file and exits with appropriate status code
  • Added --config flag: Allows specifying configuration file path (overrides environment variables)
  • Detailed validation output: Shows endpoint count, alerting providers, storage type, and external endpoints
  • Proper exit codes: Returns 0 for valid config, 1 for invalid config (CI/CD ready)
  • Backward compatibility: Maintains existing environment variable support

Usage

# Validate configuration file
./gatus --validate --config /path/to/config.yaml

# Use with environment variable
GATUS_CONFIG_PATH=/path/to/config.yaml ./gatus --validate

# CI/CD integration
if ! ./gatus --validate; then
    echo "Configuration validation failed"
    exit 1
fi

Example Output

Validating configuration: config.yaml
Configuration validation passed!
  - Endpoints: 7
  - Storage: memory
Configuration is valid and ready to use

Benefits

  • CI/CD Integration: Enable configuration validation in deployment pipelines
  • DevOps Friendly: Quick validation without full application startup
  • Error Prevention: Catch configuration issues before deployment
  • Professional Workflow: Supports modern infrastructure-as-code practices

Testing

  • ✅ Validates configuration using existing config.LoadConfiguration() logic
  • ✅ Proper error handling and exit codes
  • ✅ Help flag displays new options correctly
  • ✅ Backward compatibility maintained
  • ✅ No breaking changes to existing functionality

This addresses a gap that many monitoring tools have - the ability to validate configuration without starting the full service, which is essential for automated deployment workflows.

- Add --validate flag to validate configuration file without starting server
- Add --config flag to specify configuration file path
- Implement validateConfigurationAndExit() function with detailed output
- Display endpoint count, alerting providers, and storage type
- Exit with appropriate status codes for CI/CD integration
- Maintain backward compatibility with existing environment variables

This addresses a common need for configuration validation in CI/CD pipelines
and deployment scripts without requiring full application startup.
@github-actions github-actions bot added the feature New feature or request label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant