diff options
-rwxr-xr-x | lorry-controller-webapp | 10 | ||||
-rw-r--r-- | lorrycontroller/gerrit.py | 11 | ||||
-rw-r--r-- | lorrycontroller/gitlab.py | 15 |
3 files changed, 25 insertions, 11 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp index 6fc827e..e60f00c 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -143,6 +143,16 @@ class WEBAPP(cliapp.Application): ['publish-failures'], 'make the status page show failure logs from lorry') + self.settings.string( + ['downstream-ssh-url'], + 'URL for Downstream Host SSH service (Gerrit)', + metavar='URL') + + self.settings.string( + ['downstream-http-url'], + 'URL for Downstream Host HTTP(S) service (GitLab)', + metavar='URL') + for downstream_type in lorrycontroller.downstream_types.values(): downstream_type.add_app_settings(self.settings) 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.''' |