Fix build notifications

This commit is contained in:
Joseph Schorr 2016-09-21 14:37:23 -04:00
parent 502fa23d31
commit af79fde50d
2 changed files with 28 additions and 4 deletions

View file

@ -61,13 +61,24 @@ class NotificationEvent(object):
@classmethod
def get_event(cls, eventname):
for subc in cls.__subclasses__():
if subc.event_name() == eventname:
return subc()
found = NotificationEvent._get_event(cls, eventname)
if found is not None:
return found
raise InvalidNotificationEventException('Unable to find event: %s' % eventname)
@staticmethod
def _get_event(cls, eventname):
for subc in cls.__subclasses__():
if subc.event_name() is None:
found = NotificationEvent._get_event(subc, eventname)
if found is not None:
return found
elif subc.event_name() == eventname:
return subc()
class RepoPushEvent(NotificationEvent):
@classmethod
def event_name(cls):
@ -140,6 +151,10 @@ class VulnerabilityFoundEvent(NotificationEvent):
class BaseBuildEvent(NotificationEvent):
@classmethod
def event_name(cls):
return None
def should_perform(self, event_data, notification_data):
event_config = json.loads(notification_data.event_config_json)
ref_regex = event_config.get('ref-regex') or None