Skip to content

Commit

Permalink
Merge pull request #35 from openinfradev/fix_snr
Browse files Browse the repository at this point in the history
feature. fix check logic.
  • Loading branch information
ktkfree authored Apr 24, 2024
2 parents 7375c83 + 18aa85d commit 9324332
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmd/server/system_notification_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,28 @@ func processSystemNotificationRule() error {
log.Error(context.TODO(), err)
continue
}
rulerConfig.Groups = rc.Groups

if rc.Groups == nil || len(rc.Groups) == 0 {
continue
}

// Check exist
for _, systemNotificationRule := range rc.Groups[0].Rules {
exist := false
for i, rule := range rulerConfig.Groups[0].Rules {
if rule.Annotations.SystemNotificationRuleId == systemNotificationRule.Annotations.SystemNotificationRuleId {
rulerConfig.Groups[0].Rules[i] = systemNotificationRule
exist = true
break
}
}

if !exist {
rulerConfig.Groups[0].Rules = append(rulerConfig.Groups[0].Rules, systemNotificationRule)
}
}

//rulerConfig.Groups = rc.Groups

/*
outYaml, err := yaml.Marshal(rulerConfig)
Expand Down

0 comments on commit 9324332

Please sign in to comment.