Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func match(in *v1alpha1.Input, e corev1.Event) bool { //nolint:gocyclo // This m
return false
}

if in.Reason != "" && in.Reason != e.Reason {
return false
}

if in.Count != 0 && in.Count >= e.Count {
return false
}
Expand Down
35 changes: 35 additions & 0 deletions fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ func TestMatch(t *testing.T) {
match: true,
},
},
"MatchesReasonOnly": {
args: args{
in: &v1alpha1.Input{
Type: "BackOff",
},
e: corev1.Event{
Type: "BackOff",
},
},
want: want{
match: true,
},
},
"MatchesNameOnly": {
args: args{
in: &v1alpha1.Input{
Expand Down Expand Up @@ -115,6 +128,28 @@ func TestMatch(t *testing.T) {
match: false,
},
},
"DoesntMatchReason": {
args: args{
in: &v1alpha1.Input{
Reason: "BackOff",
InvolvedObject: corev1.ObjectReference{
Name: "oom-killed",
Namespace: "default",
},
},
e: corev1.Event{
Type: "Warning",
Reason: "FailedScheduling",
InvolvedObject: corev1.ObjectReference{
Name: "oom-killed",
Namespace: "default",
},
},
},
want: want{
match: false,
},
},
"DoesntMatchKind": {
args: args{
in: &v1alpha1.Input{
Expand Down
3 changes: 3 additions & 0 deletions input/v1alpha1/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type Input struct {
// Type of this event (Normal, Warning).
// +optional
Type string `json:"type"`
// Reason correlated to the Event. e.g. BackOff.
// +optional
Reason string `json:"reason"`
// InvolvedObject specifies properties of the Object that can be used to
// filter incoming events.
// +optional
Expand Down
3 changes: 3 additions & 0 deletions package/input/filter.event.fn.upbound.io_inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ spec:
type: string
metadata:
type: object
reason:
description: Reason correlated to the Event. e.g. BackOff.
type: string
type:
description: Type of this event (Normal, Warning).
type: string
Expand Down