ConfGuard
A Rust-based configuration management tool for securing and managing environment files across different deployment stages.
Overview
ConfGuard helps manage sensitive configuration files by:
- Moving configuration files to a secure, centralized location
- Creating symbolic links to maintain project structure
- Supporting multiple environment configurations (local, test, integration, production)
- Integrating with SOPS for encryption/decryption workflows
- Providing IDE integration for development workflows
Features
Core Functionality
- Guard Projects: Secure existing projects by moving
.envrcfiles to a managed location - Multi-Environment Support: Automatically creates environment files for different stages
- Symbolic Link Management: Maintains project structure while securing configurations
- SOPS Integration: Built-in support for encrypting/decrypting sensitive files
- IDE Integration: Creates IntelliJ/VSCode run configurations
Environment Files
When guarding a project, ConfGuard automatically creates multiple environment files:
local.env- Local development environmenttest.env- Testing environmentint.env- Integration/staging environmentprod.env- Production environment
Each file contains export RUN_ENV="<environment>" to identify the active environment.
Installation
Usage
Basic Commands
Guard a Project
Secure an existing project with a .envrc file:
This will:
- Move the
.envrcfile to a secure location - Create a symbolic link in its place
- Generate environment files (local.env, test.env, int.env, prod.env)
- Set up SOPS environment structure
- Create IDE run configurations
Show Project Status
Display information about a guarded project:
Unguard a Project
Remove ConfGuard management and restore original files:
Initialize New Project
Create a new .envrc file from template:
Advanced Commands
Guard Single File
Guard an individual file within a project:
Relink Configurations
Restore broken symbolic links:
Replace Link with Target
Convert a symbolic link back to a regular file:
Fix Run Configurations
Update IDE run configurations:
SOPS Integration
Initialize SOPS Configuration
Encrypt Files
Decrypt Files
Clean Encrypted Files
Configuration
Environment Variables
CONFGUARD_BASE_DIR: Override default base directory (default:$HOME/xxx/rs-cg)CONFGUARD_VERSION: Override configuration version
File Structure
When a project is guarded, files are organized as:
$CONFGUARD_BASE_DIR/
├── guarded/
│ └── <project-name-uuid>/
│ ├── dot.envrc # Original .envrc content
│ └── environments/
│ ├── local.env # export RUN_ENV="local"
│ ├── test.env # export RUN_ENV="test"
│ ├── int.env # export RUN_ENV="int"
│ └── prod.env # export RUN_ENV="prod"
└── confguard.toml # SOPS configuration
SOPS Configuration
Create confguard.toml in your base directory:
= "your-gpg-key-id"
= ["env"]
= ["local.env", "test.env"]
= ["enc"]
= []
Development
Building
Testing
# Run all tests
# Run specific test module
Project Structure
src/
├── cli/ # Command-line interface
├── core/ # Core guarding functionality
├── sops/ # SOPS encryption integration
├── util/ # Utility functions
└── errors.rs # Error handling with thiserror
Error Handling
ConfGuard uses thiserror for structured error handling, providing specific error types for different failure scenarios:
- File system operations
- Configuration validation
- SOPS integration
- Project state validation
Contributing
- Follow Rust style guidelines
- Add tests for new functionality
- Update documentation
- Ensure all tests pass:
cargo test -- --test-threads=1
License
[License information would go here]