mirror of
https://github.com/resmoio/kubernetes-event-exporter.git
synced 2026-08-24 01:06:22 +00:00
@@ -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
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user