Skip to content

Commit

Permalink
master | do not return error when just do not have config file
Browse files Browse the repository at this point in the history
  • Loading branch information
edutomesco committed May 23, 2024
1 parent 72661c1 commit e2cbea7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,17 @@ func InitConfig() (*Config, error) {
if err != nil {
switch err.(type) {
default:
log.Println("Enter 0")
return nil, fmt.Errorf("fatal error loading config file: %s", err)
case viper.ConfigFileNotFoundError:
log.Println("Enter 1")
return nil, errors.New("No config file found. Using defaults and environment variables")
log.Println("No config file found. Using defaults and environment variables")
return nil, nil
}
}

bindEnvs(Configuration)

err = viper.Unmarshal(&Configuration)
if err != nil {
log.Println("Enter 2")
return nil, fmt.Errorf("fatal error loading config file: %s", err)
}
defaults.SetDefaults(&Configuration)
Expand All @@ -117,7 +115,6 @@ func InitConfig() (*Config, error) {

if Configuration.Integrity.AggregateMode {
if Configuration.Bloock.ApiKey == "" {
log.Println("Enter 3")
return nil, errors.New("aggregate mode requires a BLOOCK Api Key set")
}
}
Expand Down

0 comments on commit e2cbea7

Please sign in to comment.