Add flexible configuration with custom file path support

\n- Add DLC_CONFIG_FILE environment variable for custom config paths\n- Update config.go to support both default and custom config file locations\n- Update README.md and AGENTS.md with configuration documentation\n- Remove /Users/gabrielradureau/.dancelessonscoach/ directory approach\n- Add os import to config.go\n- Test all configuration scenarios
This commit is contained in:
Gabriel Radureau
2026-04-03 15:50:18 +02:00
parent f50de95f05
commit eaaa63d74e
4 changed files with 142 additions and 10 deletions

View File

@@ -141,7 +141,15 @@ go run cmd/server/main.go &
**Configuration File Support:**
A `config.example.yaml` file is provided as a template:
A `config.example.yaml` file is provided as a template. By default, the application looks for `config.yaml` in the current working directory.
To specify a custom config file path, set the `DLC_CONFIG_FILE` environment variable:
```bash
DLC_CONFIG_FILE="/path/to/config.yaml" go run ./cmd/server
```
Example `config.yaml`:
```yaml
server:
@@ -153,10 +161,12 @@ shutdown:
```
**Configuration Loading:**
- Environment variables take precedence over defaults
- **File-based configuration** takes highest precedence
- **Environment variables** override defaults but are overridden by config file
- **Default values** are used when no other configuration is provided
- All configuration is validated on startup
- Invalid configurations cause server startup failure
- Configuration values are logged at startup
- Configuration values and source are logged at startup
**Verification:**
```bash