diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-05-14 00:51:49 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-06-01 17:03:47 +0100 |
commit | f5d6b9a5124dd133251aed8202e0ba8a4dda4f4a (patch) | |
tree | fc470edb16fef9c426cd063cb66461dbce82d3ad | |
parent | ce311a3c803515eb95c761a3a2838b093a4ea3cd (diff) | |
download | lorry-controller-f5d6b9a5124dd133251aed8202e0ba8a4dda4f4a.tar.gz |
GitlabUpstream: Use HTTPS unless explicitly configured not to
Currently we always use the 'http' scheme to talk to GitLab's REST
API. Use the 'https' scheme instead, if the configured protocol
is 'https' or 'ssh' (as the SSH server doesn't expose this API).
-rw-r--r-- | lorrycontroller/gitlab.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lorrycontroller/gitlab.py b/lorrycontroller/gitlab.py index 58bf67f..e77e4bb 100644 --- a/lorrycontroller/gitlab.py +++ b/lorrycontroller/gitlab.py @@ -130,7 +130,10 @@ class GitlabUpstream(hosts.UpstreamHost): def __init__(self, host_info): self._protocol = host_info['protocol'] - url = 'http://%(host)s/' % host_info + if self._protocol == 'ssh': + url = 'https://%(host)s/' % host_info + else: + url = '%(protocol)s://%(host)s/' % host_info self.gl = _init_gitlab(url, host_info['type_params']['private-token']) def list_repos(self): |