Add config loading and dry-run validation

This commit is contained in:
2026-05-31 01:53:13 +00:00
parent 22d0424232
commit 29dbad2967
16 changed files with 928 additions and 17 deletions

29
internal/config/load.go Normal file
View File

@@ -0,0 +1,29 @@
package config
import (
"fmt"
"os"
"gopkg.in/yaml.v3"
)
func LoadFile(path string) (Config, error) {
file, err := os.Open(path)
if err != nil {
return Config{}, fmt.Errorf("load config %q: %w", path, err)
}
defer file.Close()
var cfg Config
decoder := yaml.NewDecoder(file)
decoder.KnownFields(true)
if err := decoder.Decode(&cfg); err != nil {
return Config{}, fmt.Errorf("parse config %q: %w", path, err)
}
ApplyDefaults(&cfg)
if err := Validate(cfg); err != nil {
return Config{}, fmt.Errorf("validate config %q: %w", path, err)
}
return cfg, nil
}