Fix the spawn_notification to work in all cases and clean up some of the remaining code

This commit is contained in:
Joseph Schorr 2014-07-18 16:34:52 -04:00
parent 591cd020b8
commit 752efb9e0f
17 changed files with 18379 additions and 18415 deletions

View file

@ -17,6 +17,7 @@ from werkzeug.routing import BaseConverter
from functools import wraps
from config import getFrontendVisibleConfig
from external_libraries import get_external_javascript, get_external_css
from endpoints.notificationhelper import spawn_notification
import features
@ -231,41 +232,15 @@ def start_build(repository, dockerfile_id, tags, build_name, subdir, manual,
'build_id': build_request.uuid,
'build_name': build_name,
'docker_tags': tags,
'is_manual': manual,
'trigger_id': trigger.uuid,
'trigger_kind': trigger.service.name
'is_manual': manual
}
if trigger:
event_data['trigger_id'] = trigger.uuid
event_data['trigger_kind'] = trigger.service.name
spawn_notification(repository, 'build_queued', event_data,
subpage='build?current=' % build_request.uuid,
subpage='build?current=%s' % build_request.uuid,
pathargs=['build', build_request.uuid])
return build_request
def spawn_notification(repository, event_name, extra_data={}, subpage=None, pathargs=[]):
homepage = 'https://quay.io/repository/%s' % repo_string
if subpage:
homepage = homepage + subpage
repo_string = '%s/%s' % (repo.namespace, repo.name)
event_data = {
'repository': repo_string,
'namespace': repo.namespace,
'name': repo.name,
'docker_url': 'quay.io/%s' % repo_string,
'homepage': homepage,
'visibility': repo.visibility.name
}
event_data.update(extra_data)
notifications = model.list_repo_notifications(repo.namespace, repo.name, event_name=event_name)
for notification in notifications:
notification_data = {
'notification_id': notification.id,
'repository_id': repository.id,
'event_data': event_data
}
path = [namespace, repository, 'notification', event_name] + pathargs
notification_queue.put(path, json.dumps(notification_data))