summaryrefslogtreecommitdiff
path: root/lorrycontroller
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-05-14 00:45:02 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-06-01 17:03:42 +0100
commitce311a3c803515eb95c761a3a2838b093a4ea3cd (patch)
tree6b76255fbc150abf7e8b7ce077b1c511114c816c /lorrycontroller
parent38697c01cc12c4e8cc57b3bb372c5cf5f34ce167 (diff)
downloadlorry-controller-ce311a3c803515eb95c761a3a2838b093a4ea3cd.tar.gz
Introduce and use downstream-{http,ssh}-url settings
Replace the current hardcoded Downstream Host parameters with application settings. In general, Downstream Host connectors will use some combination of HTTP(S) and/or SSH, so these are added in lorry-controller-webapp. Currently only the gerrit connector will use downstream-ssh-url and only the gitlab connector will use downstream-http-url. Turn *on* StrictHostKeyChecking for the gerrit connector when not talking to localhost. Closes #4.
Diffstat (limited to 'lorrycontroller')
-rw-r--r--lorrycontroller/gerrit.py11
-rw-r--r--lorrycontroller/gitlab.py15
2 files changed, 15 insertions, 11 deletions
diff --git a/lorrycontroller/gerrit.py b/lorrycontroller/gerrit.py
index dad964f..0970d63 100644
--- a/lorrycontroller/gerrit.py
+++ b/lorrycontroller/gerrit.py
@@ -32,9 +32,14 @@ class GerritDownstream(hosts.DownstreamHost):
'''
def __init__(self, app_settings):
- # XXX This needs to be configurable
- url = 'ssh://lorry@localhost:29418'
- self._ssh_command = hosts.SshCommand(url, StrictHostKeyChecking='no')
+ url = app_settings['downstream-ssh-url']
+ if url is None:
+ url = 'ssh://lorry@localhost:29418'
+ key_check = 'no'
+ else:
+ key_check = 'yes'
+ self._ssh_command = hosts.SshCommand(
+ url, StrictHostKeyChecking=key_check)
def _has_project(self, name):
# There's no 'does this project exist' command in Gerrit 2.9.4; 'list
diff --git a/lorrycontroller/gitlab.py b/lorrycontroller/gitlab.py
index 4f70f0a..58bf67f 100644
--- a/lorrycontroller/gitlab.py
+++ b/lorrycontroller/gitlab.py
@@ -37,9 +37,8 @@ class MissingGitlabModuleError(Exception):
pass
-def _init_gitlab(host, token):
+def _init_gitlab(url, token):
if gitlab:
- url = "http://" + host
return gitlab.Gitlab(url, token)
else:
raise MissingGitlabModuleError('gitlab module missing\n'
@@ -61,10 +60,10 @@ class GitlabDownstream(hosts.DownstreamHost):
app_settings.require('gitlab-private-token')
def __init__(self, app_settings):
- # XXX This needs to be configurable
- host = 'localhost'
-
- self.gl = _init_gitlab(host, app_settings['gitlab-private-token'])
+ url = app_settings['downstream-http-url']
+ if url is None:
+ url = 'http://localhost/'
+ self.gl = _init_gitlab(url, app_settings['gitlab-private-token'])
def prepare_repo(self, repo_path, metadata):
@@ -131,8 +130,8 @@ class GitlabUpstream(hosts.UpstreamHost):
def __init__(self, host_info):
self._protocol = host_info['protocol']
- self.gl = _init_gitlab(host_info['host'],
- host_info['type_params']['private-token'])
+ url = 'http://%(host)s/' % host_info
+ self.gl = _init_gitlab(url, host_info['type_params']['private-token'])
def list_repos(self):
'''List projects on a GitLab instance.'''