Don't use repository object anywhere in endpoints/api/repositorynotification
Also adds support for audit logging with repo name only
This commit is contained in:
parent
047722b295
commit
9dad44e93d
5 changed files with 36 additions and 41 deletions
|
@ -56,7 +56,7 @@ class NotificationMethod(object):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
"""
|
||||
Validates that the notification can be created with the given data. Throws
|
||||
a CannotValidateNotificationMethodException on failure.
|
||||
|
@ -88,12 +88,12 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'quay_notification'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
status, err_message, target_users = self.find_targets(repository, config_data)
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
status, err_message, target_users = self.find_targets(namespace_name, repository_name, config_data)
|
||||
if err_message:
|
||||
raise CannotValidateNotificationMethodException(err_message)
|
||||
|
||||
def find_targets(self, repository, config_data):
|
||||
def find_targets(self, namespace_name, repository_name, config_data):
|
||||
target_info = config_data['target']
|
||||
|
||||
if target_info['kind'] == 'user':
|
||||
|
@ -149,12 +149,11 @@ class EmailMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'email'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
email = config_data.get('email', '')
|
||||
if not email:
|
||||
raise CannotValidateNotificationMethodException('Missing e-mail address')
|
||||
|
||||
|
||||
record = model.repository.get_email_authorized_for_repo(_get_namespace_name_from(repository),
|
||||
repository.name, email)
|
||||
if not record or not record.confirmed:
|
||||
|
@ -185,7 +184,7 @@ class WebhookMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'webhook'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
url = config_data.get('url', '')
|
||||
if not url:
|
||||
raise CannotValidateNotificationMethodException('Missing webhook URL')
|
||||
|
@ -222,7 +221,7 @@ class FlowdockMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'flowdock'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
token = config_data.get('flow_api_token', '')
|
||||
if not token:
|
||||
raise CannotValidateNotificationMethodException('Missing Flowdock API Token')
|
||||
|
@ -274,7 +273,7 @@ class HipchatMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'hipchat'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
if not config_data.get('notification_token', ''):
|
||||
raise CannotValidateNotificationMethodException('Missing Hipchat Room Notification Token')
|
||||
|
||||
|
@ -385,7 +384,7 @@ class SlackMethod(NotificationMethod):
|
|||
def method_name(cls):
|
||||
return 'slack'
|
||||
|
||||
def validate(self, repository, config_data):
|
||||
def validate(self, namespace_name, repository_name, config_data):
|
||||
if not config_data.get('url', ''):
|
||||
raise CannotValidateNotificationMethodException('Missing Slack Callback URL')
|
||||
|
||||
|
|
Reference in a new issue