Skip to content

Commit d843087

Browse files
committed
fix: making sure 'for' attribute is always defined for alerts as this is required by RHOBS
1 parent 0cc3ee9 commit d843087

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

main.go

+12
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ type genericObj struct {
4343
Spec yaml.Node
4444
}
4545

46+
type ruleObj struct {
47+
For string `yaml:",omitempty"`
48+
Alert string
49+
}
50+
4651
type ruleGroupObj struct {
4752
Name string
4853
Interval string `yaml:",omitempty"`
54+
Rules []ruleObj
4955
}
5056

5157
type ruleGroupsObj struct {
@@ -330,6 +336,12 @@ func checkRules(rulesDirPath, tenant string, isGeneratingTemplate bool) {
330336
if ruleGroupObj.Interval == "" {
331337
return fmt.Errorf("attribute 'spec.groups[].interval' is missing for some group named '%s'", ruleGroupObj.Name)
332338
}
339+
340+
for _, ruleObj := range ruleGroupObj.Rules {
341+
if ruleObj.Alert != "" && ruleObj.For == "" {
342+
return fmt.Errorf("attribute 'spec.groups[].rules[].for' is missing for some alert named '%s' in group '%s'", ruleObj.Alert, ruleGroupObj.Name)
343+
}
344+
}
333345
}
334346
}
335347

0 commit comments

Comments
 (0)