From ec92e82966b4ee56a734d7c509872b47dfff9801 Mon Sep 17 00:00:00 2001 From: Nicolas Thauvin Date: Wed, 22 Dec 2021 14:39:24 +0100 Subject: [PATCH] fix loading of the default configuration file --- config.go | 6 ++++++ main.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 355d756..a6e6e1d 100644 --- a/config.go +++ b/config.go @@ -486,6 +486,12 @@ func loadConfigurationFile(path string) (options, error) { cfg, err := ini.Load(path) if err != nil { + if path == defaultCfgFile && errors.Is(err, os.ErrNotExist) { + // Fallback on defaults when the default configuration does not exist + l.Verbosef("default configuration file %s does not exist, skipping\n", defaultCfgFile) + return opts, nil + } + return opts, fmt.Errorf("Could load configuration file: %v", err) } diff --git a/main.go b/main.go index adfb6c3..5533ac9 100644 --- a/main.go +++ b/main.go @@ -150,7 +150,7 @@ func run() (retVal error) { // Load configuration file and allow the default configuration // file to be absent configOpts, err := loadConfigurationFile(cliOpts.CfgFile) - if err != nil && cliOpts.CfgFile != defaultCfgFile { + if err != nil { return err }