Skip to content

Commit

Permalink
chore: dont rely on slice labels (#184)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann authored Jan 27, 2024
1 parent a2c1355 commit c1195f9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions injectproxy/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,8 @@ func (r *routes) filterRules(lvalues []string, resp *apiResponse) (interface{},
for _, rg := range rgs.RuleGroups {
var rules []rule
for _, rule := range rg.Rules {
for _, lbl := range rule.Labels() {
if lbl.Name == r.label && slices.Contains(lvalues, lbl.Value) {
rules = append(rules, rule)
break
}
if lval := rule.Labels().Get(r.label); lval != "" && slices.Contains(lvalues, lval) {
rules = append(rules, rule)
}
}
if len(rules) > 0 {
Expand All @@ -231,11 +228,8 @@ func (r *routes) filterAlerts(lvalues []string, resp *apiResponse) (interface{},

filtered := []*alert{}
for _, alert := range data.Alerts {
for _, lbl := range alert.Labels {
if lbl.Name == r.label && slices.Contains(lvalues, lbl.Value) {
filtered = append(filtered, alert)
break
}
if lval := alert.Labels.Get(r.label); lval != "" && slices.Contains(lvalues, lval) {
filtered = append(filtered, alert)
}
}

Expand Down

0 comments on commit c1195f9

Please sign in to comment.