Merge branch 'rustedbuilds' of ssh://bitbucket.org/yackob03/quay into rustedbuilds
This commit is contained in:
commit
001c822d74
8 changed files with 332 additions and 59 deletions
|
@ -30,7 +30,8 @@ from auth.permissions import (ReadRepositoryPermission,
|
|||
UserPermission)
|
||||
from endpoints.common import common_login, get_route_data, truthy_param
|
||||
from endpoints.trigger import (BuildTrigger, TriggerActivationException,
|
||||
TriggerDeactivationException)
|
||||
TriggerDeactivationException, EmptyRepositoryException)
|
||||
|
||||
from util.cache import cache_control
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
@ -1378,6 +1379,39 @@ def _prepare_webhook_url(scheme, username, password, hostname, path):
|
|||
return urlparse.urlunparse((scheme, auth_hostname, path, '', '', ''))
|
||||
|
||||
|
||||
@api.route('/repository/<path:repository>/trigger/<trigger_uuid>/subdir',
|
||||
methods=['POST'])
|
||||
@api_login_required
|
||||
@parse_repository_name
|
||||
def list_build_trigger_subdirs(namespace, repository, trigger_uuid):
|
||||
permission = AdministerRepositoryPermission(namespace, repository)
|
||||
if permission.can():
|
||||
try:
|
||||
trigger = model.get_build_trigger(namespace, repository, trigger_uuid)
|
||||
except model.InvalidBuildTriggerException:
|
||||
abort(404)
|
||||
return
|
||||
|
||||
handler = BuildTrigger.get_trigger_for_service(trigger.service.name)
|
||||
user_permission = UserPermission(trigger.connected_user.username)
|
||||
if user_permission.can():
|
||||
new_config_dict = request.get_json()
|
||||
|
||||
try:
|
||||
subdirs = handler.list_build_subdirs(trigger.auth_token, new_config_dict)
|
||||
return jsonify({
|
||||
'subdir': subdirs,
|
||||
'status': 'success'
|
||||
})
|
||||
except EmptyRepositoryException as e:
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'message': e.msg
|
||||
})
|
||||
|
||||
abort(403) # Permission denied
|
||||
|
||||
|
||||
@api.route('/repository/<path:repository>/trigger/<trigger_uuid>/activate',
|
||||
methods=['POST'])
|
||||
@api_login_required
|
||||
|
|
Reference in a new issue