Skip to content

Commit

Permalink
Add json logic error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
acbox committed May 9, 2023
1 parent 43c3109 commit c70596a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/sloop/ingress/kubewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func (i *kubeWatcherImpl) eventExcluded(kind string, resourceJson string) (bool)
for _, logic := range filters {
logicJson, err := json.Marshal(logic)
if err != nil {
glog.Errorf(`Failed to parse event filtering rule "%s": %s`, logic, err)
glog.Errorf(`Failed to parse event filtering rule "%s": %s`, string(logicJson), err)
return false
}
var result bytes.Buffer
Expand All @@ -398,6 +398,10 @@ func (i *kubeWatcherImpl) eventExcluded(kind string, resourceJson string) (bool)
strings.NewReader(resourceJson),
&result,
)
if err != nil {
glog.Errorf(`Failed to apply event filtering rule "%s": %s`, string(logicJson), err)
return false
}
resultBool := strings.Contains(result.String(), "true")
if resultBool {
truncated, _ := common.Truncate(resourceJson, 40)
Expand Down

0 comments on commit c70596a

Please sign in to comment.