Altering: validate that the mute time intervals exist when updating routing tree (#51573)

* validate that the mute time intervals exist when updating routing tree

* run lint

* add tests
This commit is contained in:
Jean-Philippe Quéméner
2022-07-05 13:09:17 -04:00
committed by GitHub
parent b9c7eb1380
commit 4a76436be2
3 changed files with 102 additions and 1 deletions
@@ -114,6 +114,21 @@ func (r *Route) ValidateReceivers(receivers map[string]struct{}) error {
return nil
}
func (r *Route) ValidateMuteTimes(muteTimes map[string]struct{}) error {
for _, name := range r.MuteTimeIntervals {
if _, exists := muteTimes[name]; !exists {
return fmt.Errorf("mute time interval '%s' does not exist", name)
}
}
for _, child := range r.Routes {
err := child.ValidateMuteTimes(muteTimes)
if err != nil {
return err
}
}
return nil
}
func (mt *MuteTimeInterval) Validate() error {
s, err := yaml.Marshal(mt.MuteTimeInterval)
if err != nil {