Skip to content

Commit

Permalink
chore: dont rely on slice labels
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann committed Jan 26, 2024
1 parent 2861938 commit af48549
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 rule.Labels().Has(r.label) && slices.Contains(lvalues, rule.Labels().Get(r.label)) {
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 alert.Labels.Has(r.label) && slices.Contains(lvalues, alert.Labels.Get(r.label)) {
filtered = append(filtered, alert)
}
}

Expand Down

0 comments on commit af48549

Please sign in to comment.