Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge camelCase properties from config file correctly with environment variables #231

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func newConfig(logger *zap.Logger) (Config, error) {
if configFilepath == "" {
logger.Info("the env variable '" + envKey + "' is not set, therefore no YAML config will be loaded")
} else {
err := k.Load(file.Provider(configFilepath), yaml.Parser())
err := k.Load(file.Provider(configFilepath), yaml.Parser(), koanf.WithMergeFunc(func(src, dest map[string]interface{}) error {
dest = src
return nil
}))
Comment on lines +64 to +67
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only called if you actually provide a YAML config file and therefore this does not fix the referenced issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Thank you for the hint. I missed the fact that no config file was referenced in the linked issue. I just had a similar problem where I wanted to overwrite some values from the config file with individual environment variables. Should I create a new issue for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add that to the issue, but the fix I proposed there would fix this as well

if err != nil {
return Config{}, fmt.Errorf("failed to parse YAML config: %w", err)
}
Expand Down