Skip to content

Commit

Permalink
Fix Bug on Events Configuration Equal function
Browse files Browse the repository at this point in the history
If Config.Events was nil, it would cause an null pointer exception
  • Loading branch information
cesnietor committed Dec 16, 2020
1 parent 3316e6a commit f9492f5
Show file tree
Hide file tree
Showing 2 changed files with 411 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/notification/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,18 @@ func (t *Config) Equal(events []EventType, prefix, suffix string) bool {
newFilter = append(newFilter, FilterRule{Name: "suffix", Value: suffix})
}

passFilters := EqualFilterRuleList(t.Filter.S3Key.FilterRules, newFilter)
// if it matches events and filters, mark the index for deletion
return passEvents && passFilters
if len(newFilter) > 0 {
// compare newFilter with Config.Filter
if t.Filter != nil {
passFilters := EqualFilterRuleList(t.Filter.S3Key.FilterRules, newFilter)
return passEvents && passFilters
}
// if Config is nil, they are not equal
return false
}

// if matches events and t.filter == nil
return (t.Filter == nil) && passEvents
}

// TopicConfig carries one single topic notification configuration
Expand Down
Loading

0 comments on commit f9492f5

Please sign in to comment.