Update for merge and make additional interface improvements

This commit is contained in:
Joseph Schorr 2017-07-19 11:05:50 -04:00
parent 543cba352b
commit e7d6e60d97
10 changed files with 85 additions and 170 deletions

View file

@ -3,7 +3,7 @@ import time
import re
from datetime import datetime
from notifications import build_event_data
from notifications import build_repository_event_data
from util.jinjautil import get_template_env
from util.secscan import PRIORITY_LEVELS, get_priority_for_index
@ -40,7 +40,7 @@ class NotificationEvent(object):
'notification_data': notification_data
})
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
"""
Returns sample data for testing the raising of this notification, with an example notification.
"""
@ -98,8 +98,8 @@ class RepoPushEvent(NotificationEvent):
def get_summary(self, event_data, notification_data):
return 'Repository %s updated' % (event_data['repository'])
def get_sample_data(self, repository, event_config):
return build_event_data(repository, {
def get_sample_data(self, namespace_name, repo_name, event_config):
return build_repository_event_data(namespace_name, repo_name, {
'updated_tags': {'latest': 'someimageid', 'foo': 'anotherimage'},
'pruned_image_count': 3
})
@ -132,9 +132,9 @@ class VulnerabilityFoundEvent(NotificationEvent):
return 'info'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
level = event_config.get(VulnerabilityFoundEvent.CONFIG_LEVEL, 'Critical')
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'tags': ['latest', 'prod', 'foo', 'bar', 'baz'],
'image': 'some-image-id',
'vulnerability': {
@ -219,9 +219,9 @@ class BuildQueueEvent(BaseBuildEvent):
def get_level(self, event_data, notification_data):
return 'info'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
build_uuid = 'fake-build-id'
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'is_manual': False,
'build_id': build_uuid,
'build_name': 'some-fake-build',
@ -257,9 +257,9 @@ class BuildStartEvent(BaseBuildEvent):
def get_level(self, event_data, notification_data):
return 'info'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
build_uuid = 'fake-build-id'
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'build_id': build_uuid,
'build_name': 'some-fake-build',
'docker_tags': ['latest', 'foo', 'bar'],
@ -284,9 +284,9 @@ class BuildSuccessEvent(BaseBuildEvent):
def get_level(self, event_data, notification_data):
return 'success'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
build_uuid = 'fake-build-id'
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'build_id': build_uuid,
'build_name': 'some-fake-build',
'docker_tags': ['latest', 'foo', 'bar'],
@ -312,9 +312,9 @@ class BuildFailureEvent(BaseBuildEvent):
def get_level(self, event_data, notification_data):
return 'error'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
build_uuid = 'fake-build-id'
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'build_id': build_uuid,
'build_name': 'some-fake-build',
'docker_tags': ['latest', 'foo', 'bar'],
@ -351,9 +351,9 @@ class BuildCancelledEvent(BaseBuildEvent):
def get_level(self, event_data, notification_data):
return 'info'
def get_sample_data(self, repository, event_config):
def get_sample_data(self, namespace_name, repo_name, event_config):
build_uuid = 'fake-build-id'
return build_event_data(repository, {
return build_repository_event_data(namespace_name, repo_name, {
'build_id': build_uuid,
'build_name': 'some-fake-build',
'docker_tags': ['latest', 'foo', 'bar'],