Skip to content

Commit

Permalink
fix:eventsource crash on cast #3238 (#3282)
Browse files Browse the repository at this point in the history
Signed-off-by: MenD32 <[email protected]>
  • Loading branch information
Daimanta authored and MenD32 committed Sep 23, 2024
1 parent 719646f commit ef78747
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Organizations below are **officially** using Argo Events. Please send a PR with
1. [Mobimeo GmbH](https://mobimeo.com/en/home/)
1. [OneCause](https://www.onecause.com/)
1. [Pinnacle Reliability](https://pinnaclereliability.com/)
1. [PDOK](https://pdok.nl)
1. [Phrase](https://www.phrase.com/)
1. [Produvar](https://www.produvar.com/)
1. [ProPoint Solutions](https://supersalon.com)
Expand Down
11 changes: 10 additions & 1 deletion eventsources/sources/resource/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"os"
"reflect"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -287,7 +288,15 @@ func passFilters(event *InformerEvent, filter *v1alpha1.ResourceFilter, startTim
if filter == nil {
return true
}
uObj := event.Obj.(*unstructured.Unstructured)

var uObj *unstructured.Unstructured
if castEventObject, ok := event.Obj.(*unstructured.Unstructured); ok {
uObj = castEventObject
} else {
log.Infof("event object is not of type '*unstructured.Unstructured' but of type '%s'\n", reflect.TypeOf(event.Obj).Name())
return false
}

if len(filter.Prefix) > 0 && !strings.HasPrefix(uObj.GetName(), filter.Prefix) {
log.Infof("resource name does not match prefix. resource-name: %s, prefix: %s\n", uObj.GetName(), filter.Prefix)
return false
Expand Down

0 comments on commit ef78747

Please sign in to comment.