Add default values for AlertEvery

There is also a test error corrected in TestMonitorFailureAlertEvery
where the same test conditions were repeated twice.
This commit is contained in:
Ian Fijolek
2022-12-19 11:15:34 -08:00
parent deec04bf0d
commit 7d87c3d036
3 changed files with 38 additions and 24 deletions
+5
View File
@@ -15,6 +15,7 @@ var errInvalidConfig = errors.New("Invalid configuration")
type Config struct {
CheckInterval SecondsOrDuration `yaml:"check_interval"`
DefaultAlertAfter int16 `yaml:"default_alert_after"`
DefaultAlertEvery *int16 `yaml:"default_alert_every"`
DefaultAlertDown []string `yaml:"default_alert_down"`
DefaultAlertUp []string `yaml:"default_alert_up"`
Monitors []*Monitor
@@ -143,6 +144,10 @@ func (config *Config) Init() (err error) {
monitor.AlertAfter = config.DefaultAlertAfter
}
if monitor.AlertEvery == nil && config.DefaultAlertEvery != nil {
monitor.AlertEvery = config.DefaultAlertEvery
}
if len(monitor.AlertDown) == 0 && len(config.DefaultAlertDown) > 0 {
monitor.AlertDown = config.DefaultAlertDown
}