Fix forced overrides

This commit is contained in:
2025-01-05 13:09:59 -05:00
parent 208e31c3d4
commit 4a99f06987
4 changed files with 74 additions and 39 deletions

View File

@ -7,7 +7,7 @@ import (
"os"
"runtime/debug"
"github.com/caarlos0/env/v9"
"github.com/caarlos0/env/v11"
"gopkg.in/yaml.v3"
)
@ -39,7 +39,7 @@ func LoadConfig(ctx context.Context) (context.Context, error) {
}
func loadConfig(configPath string) (*AppConfig, error) {
cfg := newAppConfig()
cfg := *DefaultConfig
if configPath != "" {
file, err := os.Open(configPath)
@ -49,16 +49,16 @@ func loadConfig(configPath string) (*AppConfig, error) {
defer file.Close()
decoder := yaml.NewDecoder(file)
if err := decoder.Decode(cfg); err != nil {
if err := decoder.Decode(&cfg); err != nil {
return nil, fmt.Errorf("could not decode config file: %w", err)
}
}
if err := env.Parse(cfg); err != nil {
if err := env.Parse(&cfg); err != nil {
return nil, fmt.Errorf("could not parse environment variables: %w", err)
}
return cfg, nil
return &cfg, nil
}
func getVersion() string {