Skip to content

Commit

Permalink
Remove checks and return all errors in config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jraddaoui committed Apr 22, 2024
1 parent 9511b4b commit cc95b17
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions internal/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -47,25 +48,11 @@ type Configuration struct {

func (c Configuration) Validate() error {
// TODO: should this validate all the fields in Configuration?
if config, ok := interface{}(c.Upload).(ConfigurationValidator); ok {
err := config.Validate()
if err != nil {
return err
}
}
if config, ok := interface{}(c.API.Auth).(ConfigurationValidator); ok {
err := config.Validate()
if err != nil {
return err
}
}
if config, ok := interface{}(c.Preprocessing).(ConfigurationValidator); ok {
err := config.Validate()
if err != nil {
return err
}
}
return nil
apiAuthErr := c.API.Auth.Validate()
preprocessingErr := c.Preprocessing.Validate()
uploadErr := c.Upload.Validate()

return errors.Join(apiAuthErr, preprocessingErr, uploadErr)
}

func Read(config *Configuration, configFile string) (found bool, configFileUsed string, err error) {
Expand Down

0 comments on commit cc95b17

Please sign in to comment.