From 7426a540dd701b6047ba2eadfa09c35c9ce9541e Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sat, 2 May 2015 13:31:54 -0400 Subject: [PATCH] initial gitlab angular stuff --- endpoints/trigger.py | 2 +- requirements.txt | 1 + .../trigger/gitlab/trigger-description.html | 19 ++++++++++ static/js/services/key-service.js | 5 +++ static/js/services/trigger-service.js | 36 +++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 static/directives/trigger/gitlab/trigger-description.html diff --git a/endpoints/trigger.py b/endpoints/trigger.py index 88854a270..4ae92ceae 100644 --- a/endpoints/trigger.py +++ b/endpoints/trigger.py @@ -1094,7 +1094,7 @@ class GitLabBuildTrigger(BuildTriggerHandler): return 'gitlab' def _get_authorized_client(self): - host = app.config.get('GITLAB_TRIGGER_CONFIG', {}).get('HOSTNAME', '') + host = app.config.get('GITLAB_TRIGGER_CONFIG', {}).get('GITLAB_ENDPOINT', '') auth_token = self.auth_token or 'invalid' return gitlab.Gitlab(host, oauth_token=auth_token) diff --git a/requirements.txt b/requirements.txt index 8c3ca0f2f..6d8962281 100644 --- a/requirements.txt +++ b/requirements.txt @@ -70,3 +70,4 @@ git+https://github.com/DevTable/container-cloud-config.git git+https://github.com/DevTable/python-etcd.git git+https://github.com/NateFerrero/oauth2lib.git git+https://github.com/coreos/py-bitbucket.git +git+https://github.com/coreos/pyapi-gitlab.git diff --git a/static/directives/trigger/gitlab/trigger-description.html b/static/directives/trigger/gitlab/trigger-description.html new file mode 100644 index 000000000..fd93d6a81 --- /dev/null +++ b/static/directives/trigger/gitlab/trigger-description.html @@ -0,0 +1,19 @@ + + + Push to GitLab repository + + {{ trigger.config.build_source }} + +
+
+ Branches/Tags: + Matching Regular Expression {{ trigger.config.branchtag_regex }} + (All Branches and Tags) +
+ +
+ Dockerfile: + {{ TriggerService.getDockerfileLocation(trigger) }} +
+
+
diff --git a/static/js/services/key-service.js b/static/js/services/key-service.js index e38ba7b26..3f373a294 100644 --- a/static/js/services/key-service.js +++ b/static/js/services/key-service.js @@ -8,10 +8,12 @@ angular.module('quay').factory('KeyService', ['$location', 'Config', function($l keyService['stripePublishableKey'] = Config['STRIPE_PUBLISHABLE_KEY']; + keyService['gitlabTriggerClientId'] = oauth['GITLAB_TRIGGER_CONFIG']['CLIENT_ID']; keyService['githubTriggerClientId'] = oauth['GITHUB_TRIGGER_CONFIG']['CLIENT_ID']; keyService['githubLoginClientId'] = oauth['GITHUB_LOGIN_CONFIG']['CLIENT_ID']; keyService['googleLoginClientId'] = oauth['GOOGLE_LOGIN_CONFIG']['CLIENT_ID']; + keyService['gitlabRedirectUri'] = Config.getURL('/oauth2/gitlab/callback'); keyService['githubRedirectUri'] = Config.getUrl('/oauth2/github/callback'); keyService['googleRedirectUri'] = Config.getUrl('/oauth2/google/callback'); @@ -23,6 +25,9 @@ angular.module('quay').factory('KeyService', ['$location', 'Config', function($l keyService['githubTriggerEndpoint'] = oauth['GITHUB_TRIGGER_CONFIG']['GITHUB_ENDPOINT']; keyService['githubTriggerAuthorizeUrl'] = oauth['GITHUB_TRIGGER_CONFIG']['AUTHORIZE_ENDPOINT']; + keySerivce['gitlabTriggerEndpoint'] = oauth['GITLAB_TRIGGER_CONFIG']['GITLAB_ENDPOINT']; + keyService['gitlabTriggerAuthorizeUrl'] = oauth['GITLAB_TRIGGER_CONFIG']['AUTHORIZE_ENDPOINT']; + keyService['githubLoginScope'] = 'user:email'; if (oauth['GITHUB_LOGIN_CONFIG']['ORG_RESTRICT']) { keyService['githubLoginScope'] += ',read:org'; diff --git a/static/js/services/trigger-service.js b/static/js/services/trigger-service.js index c8beec42e..42202ee34 100644 --- a/static/js/services/trigger-service.js +++ b/static/js/services/trigger-service.js @@ -88,6 +88,42 @@ angular.module('quay').factory('TriggerService', ['UtilService', '$sanitize', 'K } }, + 'gitlab': { + 'description': function(config) { + var source = UtilService.textToSafeHtml(config['build_source']); + var desc = ' Push to GitLab Repository '; + desc += '' + source + ''; + desc += '
Dockerfile folder: //' + UtilService.textToSafeHtml(config['subdir']); + return desc; + }, + 'run_parameters': [ + { + 'title': 'Branch', + 'type': 'option', + 'name': 'branch_name' + } + ], + 'get_redirect_url': function(namespace, repository) { + var redirect_uri = KeyService['gitlabRedirectUri'] + '/trigger/' + + namespace + '/' + repository; + var authorize_url = KeyService['gitlabTriggerAuthorizeUrl']; + var client_id = KeyService['gitlabTriggerClientId']; + + return authorize_url + 'client_id=' + client_id + '&redirect_uri=' + redirect_uri; + }, + 'is_external': false, + 'is_enabled': function() { + return Features.GITLAB_BUILD; + }, + 'icon': 'fa-git-square', + 'title': function() { return 'GitLab Repository Push'; }, + 'supports_full_directory_listing': false, + 'templates': { + 'credentials': '/static/directives/trigger/githost/credentials.html', + 'trigger-description': '/static/directives/trigger/gitlab/trigger-description.html' + } + }, + 'custom-git': { 'description': function(config) { var source = UtilService.textToSafeHtml(config['build_source']);