Skip to content

Commit

Permalink
events use string regular expressions
Browse files Browse the repository at this point in the history
before, events expressions are stored in yaml as regular expressions.
now, they are stored as a string with an opening/closing slash. Those
are treated as regular expressions.
  • Loading branch information
kbrock committed Jan 20, 2021
1 parent fd29cfb commit cdf4c28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/models/event_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def self.group_and_level(event_type)

group = egroups.detect do |_, value|
GROUP_LEVELS
.detect { |lvl| value[lvl]&.any? { |typ| typ.kind_of?(String) && typ == event_type } }
.detect { |lvl| value[lvl]&.any? { |typ| !typ.starts_with?("/") && typ == event_type } }
.tap { |level_found| level = level_found || level }
end&.first

group ||= egroups.detect do |_, value|
GROUP_LEVELS
.detect { |lvl| value[lvl]&.any? { |typ| typ.kind_of?(Regexp) && typ.match(event_type) } }
.detect { |lvl| value[lvl]&.any? { |typ| typ.starts_with?("/") && Regexp.new(typ[1..-2]).match?(event_type) } }
.tap { |level_found| level = level_found || level }
end&.first

Expand Down
2 changes: 1 addition & 1 deletion spec/models/ems_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
end

let(:provider_event) { 'SomeSpecialProviderEvent' }
let(:provider_regex) { /Some.+Event/ }
let(:provider_regex) { "/Some.+Event/" }

it 'returns the provider event if configured' do
expect(described_class.event_groups[:addition][:critical]).to include('CloneTaskEvent')
Expand Down

0 comments on commit cdf4c28

Please sign in to comment.