diff --git a/engine/engine.go b/engine/engine.go index daad03c2..f5c71626 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -491,6 +491,8 @@ func (r *ruleEngine) createViolation(conditionResponse ConditionResponse, rule R } } + rule.Labels = deduplicateLabels(rule.Labels) + return konveyor.Violation{ Description: rule.Description, Labels: rule.Labels, @@ -557,3 +559,18 @@ func matchesAllSelectors(m RuleMeta, selectors ...RuleSelector) bool { } return true } + +func deduplicateLabels(labels []string) []string { + present := map[string]bool{} + uniquelabels := []string{} + + for _, label := range labels { + if !present[label] { + present[label] = true + uniquelabels = append(uniquelabels, label) + } + } + + return uniquelabels + +}