Merge pull request #79 from ivilimon/patch-1

Fix label matching bug
This commit is contained in:
Mustafa Akın
2020-08-22 15:48:20 +03:00
committed by GitHub
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ func (r *Rule) MatchesEvent(ev *kube.EnhancedEvent) bool {
if val, ok := ev.InvolvedObject.Labels[k]; !ok {
return false
} else {
matches := matchString(val, v)
matches := matchString(v, val)
if !matches {
return false
}
+15
View File
@@ -52,6 +52,21 @@ func TestBasicRegexRule(t *testing.T) {
assert.False(t, r.MatchesEvent(ev3))
}
func TestLabelRegexRule(t *testing.T) {
ev := &kube.EnhancedEvent{}
ev.InvolvedObject.Labels = map[string]string{
"version": "alpha-123",
}
r := Rule{
Labels: map[string]string{
"version": "alpha",
},
}
assert.True(t, r.MatchesEvent(ev))
}
func TestOneLabelMatchesRule(t *testing.T) {
ev := &kube.EnhancedEvent{}
ev.InvolvedObject.Labels = map[string]string{