-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: assafad <aadmi@redhat.com>
- Loading branch information
Showing
2 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package testutil | ||
|
||
import promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" | ||
|
||
func ValidateAlertNameLength(alert *promv1.Rule) []Problem { | ||
var result []Problem | ||
|
||
if len(alert.Alert) > 50 { | ||
result = append(result, Problem{ | ||
ResourceName: alert.Alert, | ||
Description: "alert name exceeds 50 characters", | ||
}) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func ValidateAlertRunbookURLAnnotation(alert *promv1.Rule) []Problem { | ||
var result []Problem | ||
|
||
runbookURL := alert.Annotations["runbook_url"] | ||
if runbookURL == "" { | ||
result = append(result, Problem{ | ||
ResourceName: alert.Alert, | ||
Description: "alert must have a runbook_url annotation", | ||
}) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func ValidateHealthImpactLabel(alert *promv1.Rule) []Problem { | ||
var result []Problem | ||
|
||
healthImpact := alert.Labels["operator_health_impact"] | ||
if healthImpact == "" { | ||
result = append(result, Problem{ | ||
ResourceName: alert.Alert, | ||
Description: "alert must have a operator_health_impact label", | ||
}) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func ValidateAlertPartOfLabel(alert *promv1.Rule) []Problem { | ||
var result []Problem | ||
|
||
partOf := alert.Labels["kubernetes_operator_part_of"] | ||
if partOf == "" { | ||
result = append(result, Problem{ | ||
ResourceName: alert.Alert, | ||
Description: "alert must have a kubernetes_operator_part_of label", | ||
}) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func ValidateAlertComponentLabel(alert *promv1.Rule) []Problem { | ||
var result []Problem | ||
|
||
partOf := alert.Labels["kubernetes_operator_component"] | ||
if partOf == "" { | ||
result = append(result, Problem{ | ||
ResourceName: alert.Alert, | ||
Description: "alert must have a kubernetes_operator_component label", | ||
}) | ||
} | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters