Skip to content

Commit 7b26e70

Browse files
committed
Change to stdlib slices.Contains
1 parent 3ba0f1d commit 7b26e70

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

cmd/alert.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"regexp"
7+
"slices"
78
"strings"
89

910
"github.com/NETWAYS/check_prometheus/internal/alert"
@@ -23,17 +24,6 @@ type AlertConfig struct {
2324

2425
var cliAlertConfig AlertConfig
2526

26-
func contains(s string, list []string) bool {
27-
// Tiny helper to see if a string is in a list of strings
28-
for _, elem := range list {
29-
if s == elem {
30-
return true
31-
}
32-
}
33-
34-
return false
35-
}
36-
3727
var alertCmd = &cobra.Command{
3828
Use: "alert",
3929
Short: "Checks the status of a Prometheus alert",
@@ -115,7 +105,7 @@ inactive = 0`,
115105

116106
// If it's not the Alert we're looking for, Skip!
117107
if cliAlertConfig.AlertName != nil {
118-
if !contains(rl.AlertingRule.Name, cliAlertConfig.AlertName) {
108+
if !slices.Contains(cliAlertConfig.AlertName, rl.AlertingRule.Name) {
119109
continue
120110
}
121111
}

0 commit comments

Comments
 (0)