##// END OF EJS Templates
integrations: expose some common methods for web based calls of integrations.
marcink -
r2580:4e61488e default
parent child Browse files
Show More
@@ -114,7 +114,31 b' class EEIntegration(IntegrationTypeBase)'
114 super(EEIntegration, self).__init__(settings)
114 super(EEIntegration, self).__init__(settings)
115
115
116
116
117 # Helpers
117 # Helpers #
118
119 # common vars for url template
120 CI_URL_VARS = [
121 'repo_name',
122 'repo_type',
123 'repo_id',
124 'repo_url',
125 # extra repo fields
126 'extra:<extra_key_name>',
127
128 # special attrs below that we handle, using multi-call
129 'branch',
130 'commit_id',
131
132 # pr events vars
133 'pull_request_id',
134 'pull_request_url',
135
136 # user who triggers the call
137 'username',
138 'user_id',
139
140 ]
141
118
142
119 def get_auth(settings):
143 def get_auth(settings):
120 from requests.auth import HTTPBasicAuth
144 from requests.auth import HTTPBasicAuth
@@ -123,3 +147,7 b' def get_auth(settings):'
123 if username and password:
147 if username and password:
124 return HTTPBasicAuth(username, password)
148 return HTTPBasicAuth(username, password)
125 return None
149 return None
150
151
152 def get_url_vars(url_vars):
153 return ', '.join('${' + x + '}' for x in url_vars)
@@ -33,7 +33,8 b' from requests.packages.urllib3.util.retr'
33 import rhodecode
33 import rhodecode
34 from rhodecode import events
34 from rhodecode import events
35 from rhodecode.translation import _
35 from rhodecode.translation import _
36 from rhodecode.integrations.types.base import IntegrationTypeBase, get_auth
36 from rhodecode.integrations.types.base import (
37 IntegrationTypeBase, get_auth, get_url_vars)
37 from rhodecode.lib.celerylib import run_task, async_task, RequestContextTask
38 from rhodecode.lib.celerylib import run_task, async_task, RequestContextTask
38
39
39 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
@@ -61,7 +62,7 b' WEBHOOK_URL_VARS = ['
61 'user_id',
62 'user_id',
62
63
63 ]
64 ]
64 URL_VARS = ', '.join('${' + x + '}' for x in WEBHOOK_URL_VARS)
65 URL_VARS = get_url_vars(WEBHOOK_URL_VARS)
65
66
66
67
67 class WebhookHandler(object):
68 class WebhookHandler(object):
General Comments 0
You need to be logged in to leave comments. Login now