summaryrefslogtreecommitdiff
path: root/lorrycontroller/readconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/readconf.py')
-rw-r--r--lorrycontroller/readconf.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index 875e982..3303f68 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -70,7 +70,7 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
added = self.add_matching_lorries_to_statedb(
statedb, section)
lorries_to_remove = lorries_to_remove.difference(added)
- elif section['type'] in ('trove', 'gitlab'):
+ elif section['type'] in lorrycontroller.upstream_types:
self.add_host(statedb, section)
host = section.get('host') or section['trovehost']
if host in hosts_to_remove:
@@ -290,9 +290,8 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute):
username = auth.get('username')
password = auth.get('password')
- type_params = {}
- if section['type'] == 'gitlab':
- type_params['private-token'] = section['private-token']
+ type_params = lorrycontroller.upstream_types[section['type']] \
+ .get_host_type_params(section)
statedb.add_host(
host=section.get('host') or section['trovehost'],
@@ -329,12 +328,12 @@ class LorryControllerConfValidator(object):
# Backward compatibility
if section['type'] == 'troves':
section['type'] = 'trove'
- if section['type'] == 'trove':
+ if section['type'] in lorrycontroller.upstream_types:
self._check_host_section(section)
+ lorrycontroller.upstream_types[section['type']] \
+ .check_host_type_params(self, section)
elif section['type'] == 'lorries':
self._check_lorries_section(section)
- elif section['type'] == 'gitlab':
- self._check_gitlab_section(section)
else:
raise ValidationError(
'unknown section type %r' % section['type'])
@@ -353,10 +352,6 @@ class LorryControllerConfValidator(object):
if type(item) is not dict:
raise ValidationError('all items must be dicts')
- def _check_gitlab_section(self, section):
- self._check_host_section(section)
- self._check_has_required_fields(section, ['private-token'])
-
def _check_host_section(self, section):
if not any(i in ('trovehost', 'host') for i in section):
self.check_has_required_fields(section, ['host'])