feat: add configuration management with YAML parsing and validation

Add internal/config package with Config struct (Server, Navidrome,
MusicBrainz, Telegram, Scanner sections), LoadConfig function for
YAML parsing, config validation (required fields, port range,
threshold range), and defaults. Include config.yaml.example matching
spec. Update main.go to use real config package instead of
placeholders. Add comprehensive tests covering valid configs,
defaults, missing files, malformed YAML, and validation boundaries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 08:47:04 +03:00
parent eb266ed5ec
commit 6ff4ec3045
8 changed files with 564 additions and 72 deletions

View File

@@ -65,14 +65,14 @@ Build the foundation layer of NaviWatcher: a greenfield Go project with zero exi
- [x] run tests — must pass before task 2
### Task 2: Configuration management
- [ ] create `internal/config/config.go` with Config struct matching spec (Server, Navidrome, MusicBrainz, Telegram, Scanner sections)
- [ ] implement `LoadConfig(path string) (*Config, error)` function that reads and parses YAML
- [ ] implement config validation (required fields, valid port range, valid threshold range 0.0-1.0)
- [ ] create `config.yaml.example` with all fields filled with placeholder values per spec section 7
- [ ] write tests for LoadConfig: valid config file
- [ ] write tests for LoadConfig: missing file, malformed YAML, invalid values
- [ ] write tests for config validation logic
- [ ] run tests — must pass before task 3
- [x] create `internal/config/config.go` with Config struct matching spec (Server, Navidrome, MusicBrainz, Telegram, Scanner sections)
- [x] implement `LoadConfig(path string) (*Config, error)` function that reads and parses YAML
- [x] implement config validation (required fields, valid port range, valid threshold range 0.0-1.0)
- [x] create `config.yaml.example` with all fields filled with placeholder values per spec section 7
- [x] write tests for LoadConfig: valid config file
- [x] write tests for LoadConfig: missing file, malformed YAML, invalid values
- [x] write tests for config validation logic
- [x] run tests — must pass before task 3
### Task 3: Database layer — schema and migrations
- [ ] create `internal/database/database.go` with DB struct and `New(dbPath string) (*DB, error)` constructor