summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>2023-01-05 12:27:42 +0000
committerJames Mills <james@mills.io>2023-01-05 12:27:42 +0000
commitf6dedea101ea5f81448aac8af30302e2e13f621f (patch)
treef07b29abb6a87da1245b0b60bfd834d178fb5906
parentd0727c2187290f22b498f20da2c0b6f2cee1f444 (diff)
fix(config): Always show config file name and abort if read fails (#46)
With this change you should always know what config tube is using. If an explicitly requested file can not be read, then tube will complain and exit. This should fix issue #45 Reviewed-on: https://git.mills.io/prologic/tube/pulls/46 Co-authored-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> Co-committed-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
-rw-r--r--main.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.go b/main.go
index 0f9331f..d18e7dc 100644
--- a/main.go
+++ b/main.go
@@ -41,14 +41,15 @@ func main() {
}
cfg := app.DefaultConfig()
+ log.Infof("Reading configuration from %s", config)
err := cfg.ReadFile(config)
- if err == nil {
- log.Infof("reading configuration from %s", config)
- } else {
- if !os.IsNotExist(err) {
+ if err != nil {
+ if flag.Lookup("config").Changed {
log.Fatal(err)
}
+ log.Infof("Reading %s failed. Starting with builtin defaults.", config)
}
+ // I'd like to add something like this here: log.Debug("Active config: %s", cfg.toJson())
a, err := app.NewApp(cfg)
if err != nil {
log.Fatal(err)