Skip to content

Commit

Permalink
Fixes #133: check if config file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mcamou committed Oct 25, 2024
1 parent 046a59f commit 4b24510
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runner/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flags

import (
"crypto/tls"
"errors"
"flag"
"fmt"
"net/url"
Expand Down Expand Up @@ -143,6 +144,10 @@ func (o *Options) ReadInConfig() (*Config, error) {
}

func (o *Options) ReadConfigFile(name string) (*Config, error) {
if _, err := os.Stat(name); errors.Is(err, os.ErrNotExist) {
return o.DefaultConfig(), fmt.Errorf("Config file %s not found, using default config", name)
}

o.viper.SetConfigFile(name)

if err := o.viper.ReadInConfig(); err != nil {
Expand Down

0 comments on commit 4b24510

Please sign in to comment.