mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
refactor: directly return error where sufficient (#2855)
This commit is contained in:
parent
8fc48476c6
commit
5d4003c291
|
@ -120,7 +120,7 @@ func doStartupChecks(config *schema.Configuration, providers *middlewares.Provid
|
|||
}
|
||||
}
|
||||
|
||||
func doStartupCheck(logger *logrus.Logger, name string, provider models.StartupCheck, disabled bool) (err error) {
|
||||
func doStartupCheck(logger *logrus.Logger, name string, provider models.StartupCheck, disabled bool) error {
|
||||
if disabled {
|
||||
logger.Debugf("%s provider: startup check skipped as it is disabled", name)
|
||||
return nil
|
||||
|
@ -130,9 +130,5 @@ func doStartupCheck(logger *logrus.Logger, name string, provider models.StartupC
|
|||
return fmt.Errorf("unrecognized provider or it is not configured properly")
|
||||
}
|
||||
|
||||
if err = provider.StartupCheck(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return provider.StartupCheck()
|
||||
}
|
||||
|
|
|
@ -33,10 +33,8 @@ func storagePersistentPreRunE(cmd *cobra.Command, _ []string) (err error) {
|
|||
|
||||
sources = append(sources, configuration.NewYAMLFileSource(configFile))
|
||||
}
|
||||
} else {
|
||||
if _, err := os.Stat(configs[0]); err == nil {
|
||||
sources = append(sources, configuration.NewYAMLFileSource(configs[0]))
|
||||
}
|
||||
} else if _, err := os.Stat(configs[0]); err == nil {
|
||||
sources = append(sources, configuration.NewYAMLFileSource(configs[0]))
|
||||
}
|
||||
|
||||
mapping := map[string]string{
|
||||
|
|
|
@ -38,22 +38,12 @@ func (n *FileNotifier) StartupCheck() (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
if err := os.WriteFile(n.path, []byte(""), fileNotifierMode); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return os.WriteFile(n.path, []byte(""), fileNotifierMode)
|
||||
}
|
||||
|
||||
// Send send a identity verification link to a user.
|
||||
func (n *FileNotifier) Send(recipient, subject, body, _ string) error {
|
||||
content := fmt.Sprintf("Date: %s\nRecipient: %s\nSubject: %s\nBody: %s", time.Now(), recipient, subject, body)
|
||||
|
||||
err := os.WriteFile(n.path, []byte(content), fileNotifierMode)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return os.WriteFile(n.path, []byte(content), fileNotifierMode)
|
||||
}
|
||||
|
|
|
@ -243,11 +243,7 @@ func (n *SMTPNotifier) StartupCheck() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := n.client.Reset(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return n.client.Reset()
|
||||
}
|
||||
|
||||
// Send is used to send an email to a recipient.
|
||||
|
|
|
@ -54,7 +54,7 @@ func (rs *RodSession) collectScreenshot(err error, page *rod.Page) {
|
|||
build := os.Getenv("BUILDKITE_BUILD_NUMBER")
|
||||
suite := strings.ToLower(os.Getenv("SUITE"))
|
||||
job := os.Getenv("BUILDKITE_JOB_ID")
|
||||
path := filepath.Join(fmt.Sprintf("%s/%s/%s/%s", base, build, suite, job)) //nolint: gocritic
|
||||
path := filepath.Join(base, build, suite, job)
|
||||
|
||||
if err := os.MkdirAll(path, 0755); err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
@ -33,7 +33,7 @@ const (
|
|||
|
||||
const (
|
||||
// Hour is an int based representation of the time unit.
|
||||
Hour = time.Minute * 60 //nolint: revive
|
||||
Hour = time.Minute * 60 //nolint:revive
|
||||
|
||||
// Day is an int based representation of the time unit.
|
||||
Day = Hour * 24
|
||||
|
|
Loading…
Reference in New Issue
Block a user