Skip to content
Snippets Groups Projects
Unverified Commit 084ffaef authored by capossele's avatar capossele
Browse files

:wrench: Fix config order

parent 3c98f872
No related branches found
No related tags found
No related merge requests found
......@@ -75,11 +75,6 @@ func init() {
// It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag)
// and ending with: .json, .toml, .yaml or .yml (in this sequence).
func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error {
// read in ENV variables
if err := _node.LoadEnvironmentVars(""); err != nil {
return err
}
flag.Parse()
if err := _node.LoadFile(*configFilePath); err != nil {
......@@ -95,6 +90,17 @@ func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error {
return err
}
// read in ENV variables
// load the env vars after default values from flags were set (otherwise the env vars are not added because the keys don't exist)
if err := _node.LoadEnvironmentVars(""); err != nil {
return err
}
// load the flags again to overwrite env vars that were also set via command line
if err := _node.LoadFlagSet(flag.CommandLine); err != nil {
return err
}
if printConfig {
PrintConfig(ignoreSettingsAtPrint...)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment