Small fixes for GitLab trigger handler, since the GitLab API is returning the wrong ID for the user's namespace
Also has a small UI improvement
This commit is contained in:
parent
059d5c656d
commit
759eee00f1
3 changed files with 13 additions and 8 deletions
|
@ -312,9 +312,14 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
||||||
def _get_namespace(self, gl_client, gl_namespace, lazy=False):
|
def _get_namespace(self, gl_client, gl_namespace, lazy=False):
|
||||||
try:
|
try:
|
||||||
if gl_namespace.attributes['kind'] == 'group':
|
if gl_namespace.attributes['kind'] == 'group':
|
||||||
return gl_client.groups.get(gl_namespace.attributes['name'], lazy=lazy)
|
return gl_client.groups.get(gl_namespace.attributes['id'], lazy=lazy)
|
||||||
|
|
||||||
return gl_client.users.get(gl_namespace.attributes['name'], lazy=lazy)
|
if gl_namespace.attributes['name'] == gl_client.user.attributes['username']:
|
||||||
|
return gl_client.users.get(gl_client.user.attributes['id'], lazy=lazy)
|
||||||
|
|
||||||
|
# Note: This doesn't seem to work for IDs retrieved via the namespaces API; the IDs are
|
||||||
|
# different.
|
||||||
|
return gl_client.users.get(gl_namespace.attributes['id'], lazy=lazy)
|
||||||
except gitlab.GitlabGetError:
|
except gitlab.GitlabGetError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ def namespaces_handler(_, request):
|
||||||
|
|
||||||
|
|
||||||
def get_projects_handler(add_permissions_block):
|
def get_projects_handler(add_permissions_block):
|
||||||
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/groups/someorg/projects$')
|
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/groups/2/projects$')
|
||||||
def projects_handler(_, request):
|
def projects_handler(_, request):
|
||||||
if not request.headers.get('Authorization') == 'Bearer foobar':
|
if not request.headers.get('Authorization') == 'Bearer foobar':
|
||||||
return {'status_code': 401}
|
return {'status_code': 401}
|
||||||
|
@ -317,7 +317,7 @@ def get_projects_handler(add_permissions_block):
|
||||||
|
|
||||||
|
|
||||||
def get_group_handler(null_avatar):
|
def get_group_handler(null_avatar):
|
||||||
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/groups/someorg$')
|
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/groups/2$')
|
||||||
def group_handler(_, request):
|
def group_handler(_, request):
|
||||||
if not request.headers.get('Authorization') == 'Bearer foobar':
|
if not request.headers.get('Authorization') == 'Bearer foobar':
|
||||||
return {'status_code': 401}
|
return {'status_code': 401}
|
||||||
|
@ -546,7 +546,7 @@ def delete_deploykey_handker(_, request):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/users/knownuser/projects$')
|
@urlmatch(netloc=r'fakegitlab', path=r'/api/v4/users/2/projects$')
|
||||||
def user_projects_list_handler(_, request):
|
def user_projects_list_handler(_, request):
|
||||||
if not request.headers.get('Authorization') == 'Bearer foobar':
|
if not request.headers.get('Authorization') == 'Bearer foobar':
|
||||||
return {'status_code': 401}
|
return {'status_code': 401}
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<img class="namespace-avatar"
|
<img class="namespace-avatar"
|
||||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||||
{{ $ctrl.local.selectedNamespace.id }}
|
{{ $ctrl.local.selectedNamespace.title }}
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
<div style="display: flex; justify-content: flex-end;">
|
<div style="display: flex; justify-content: flex-end;">
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
<img class="namespace-avatar"
|
<img class="namespace-avatar"
|
||||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||||
{{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }}
|
{{ $ctrl.local.selectedNamespace.title }}/{{ $ctrl.local.selectedRepository.name }}
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
<div class="radio" style="margin-top: 20px;">
|
<div class="radio" style="margin-top: 20px;">
|
||||||
|
@ -334,7 +334,7 @@
|
||||||
There was an error when verifying the state of <img class="namespace-avatar"
|
There was an error when verifying the state of <img class="namespace-avatar"
|
||||||
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
ng-src="{{ $ctrl.local.selectedNamespace.avatar_url }}"
|
||||||
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
ng-if="$ctrl.local.selectedNamespace.avatar_url">
|
||||||
{{ $ctrl.local.selectedNamespace.id }}/{{ $ctrl.local.selectedRepository.name }}
|
{{ $ctrl.local.selectedNamespace.title }}/{{ $ctrl.local.selectedRepository.name }}
|
||||||
</strong>
|
</strong>
|
||||||
|
|
||||||
{{ $ctrl.local.triggerAnalysis.message }}
|
{{ $ctrl.local.triggerAnalysis.message }}
|
||||||
|
|
Reference in a new issue