diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2021-09-05 18:57:59 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2021-09-05 18:57:59 -0500 |
| commit | b1cd5692b9c1139298d82ad610dad6657feb2590 (patch) | |
| tree | e1b032bc22f71a2a2c21307e02a3e127cba11746 /config.go | |
| parent | ce305f2f1a21e0a01176c1ff02668a5e1e9f57fe (diff) | |
Do not throw fatal error when missing config, this behavior will be enabled in future releases
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -13,14 +13,21 @@ type Config struct { const PLANR_CONFIG_FILE = "config.toml" -func DecodeConfig(configDir string) Config { - cfg := Config { } +// TODO: REMOVE +const STRICTLY_REQUIRE_CONFIG = false + +func DecodeConfig(configDir string) *Config { + cfg := new(Config) configFile := path.Join(configDir, PLANR_CONFIG_FILE) - if _, err := toml.DecodeFile(configFile, &cfg); err != nil { + if _, err := toml.DecodeFile(configFile, cfg); err != nil { + cfg = nil + // TODO: handle missing config - log.Fatalf("Could not decode global configuration %s: %v", configFile, err) + if STRICTLY_REQUIRE_CONFIG { + log.Fatalf("Could not decode global configuration %s: %v", configFile, err) + } } return cfg |
