refactor: directly return error where sufficient (#2855)
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 {
|
if disabled {
|
||||||
logger.Debugf("%s provider: startup check skipped as it is disabled", name)
|
logger.Debugf("%s provider: startup check skipped as it is disabled", name)
|
||||||
return nil
|
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")
|
return fmt.Errorf("unrecognized provider or it is not configured properly")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = provider.StartupCheck(); err != nil {
|
return provider.StartupCheck()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,8 @@ func storagePersistentPreRunE(cmd *cobra.Command, _ []string) (err error) {
|
||||||
|
|
||||||
sources = append(sources, configuration.NewYAMLFileSource(configFile))
|
sources = append(sources, configuration.NewYAMLFileSource(configFile))
|
||||||
}
|
}
|
||||||
} else {
|
} else if _, err := os.Stat(configs[0]); err == nil {
|
||||||
if _, err := os.Stat(configs[0]); err == nil {
|
sources = append(sources, configuration.NewYAMLFileSource(configs[0]))
|
||||||
sources = append(sources, configuration.NewYAMLFileSource(configs[0]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mapping := map[string]string{
|
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 os.WriteFile(n.path, []byte(""), fileNotifierMode)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send send a identity verification link to a user.
|
// Send send a identity verification link to a user.
|
||||||
func (n *FileNotifier) Send(recipient, subject, body, _ string) error {
|
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)
|
content := fmt.Sprintf("Date: %s\nRecipient: %s\nSubject: %s\nBody: %s", time.Now(), recipient, subject, body)
|
||||||
|
|
||||||
err := os.WriteFile(n.path, []byte(content), fileNotifierMode)
|
return os.WriteFile(n.path, []byte(content), fileNotifierMode)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,11 +243,7 @@ func (n *SMTPNotifier) StartupCheck() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := n.client.Reset(); err != nil {
|
return n.client.Reset()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send is used to send an email to a recipient.
|
// 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")
|
build := os.Getenv("BUILDKITE_BUILD_NUMBER")
|
||||||
suite := strings.ToLower(os.Getenv("SUITE"))
|
suite := strings.ToLower(os.Getenv("SUITE"))
|
||||||
job := os.Getenv("BUILDKITE_JOB_ID")
|
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 {
|
if err := os.MkdirAll(path, 0755); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -33,7 +33,7 @@ const (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Hour is an int based representation of the time unit.
|
// 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 is an int based representation of the time unit.
|
||||||
Day = Hour * 24
|
Day = Hour * 24
|
||||||
|
|
Loading…
Reference in New Issue