Skip to content

Commit

Permalink
Fix errors on loading env vars not logging anything at all
Browse files Browse the repository at this point in the history
The logging stack isn't initiated at this time, so we are just plain logging to stderr
  • Loading branch information
ccremer committed Feb 16, 2021
1 parent dc14d5b commit 8419801
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"os"
"strings"

Expand Down Expand Up @@ -141,14 +142,14 @@ func loadEnvironmentVariables() {
return s
}), nil)
if err != nil {
setupLog.Error(err, "could not load environment variables")
_, _ = fmt.Fprintf(os.Stderr, "could not load environment variables: %v\n", err)
}

if err := koanfInstance.UnmarshalWithConf("", &cfg.Config, koanf.UnmarshalConf{Tag: "koanf", FlatPaths: true}); err != nil {
setupLog.Error(err, "could not merge defaults with settings from environment variables")
_, _ = fmt.Fprintf(os.Stderr, "could not merge defaults with settings from environment variables: %v\n", err)
}
if err := cfg.Config.ValidateSyntax(); err != nil {
setupLog.Error(err, "settings invalid")
_, _ = fmt.Fprintf(os.Stderr, "settings invalid: %v\n", err)
os.Exit(2)
}
}

0 comments on commit 8419801

Please sign in to comment.