Skip to content

Commit

Permalink
fix loading of the default configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
orgrim committed Dec 23, 2021
1 parent 9a26348 commit ec92e82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit ec92e82

Please sign in to comment.