diff options
Diffstat (limited to 'lorrycontroller/readconf.py')
-rw-r--r-- | lorrycontroller/readconf.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py index a108c41..5323a3f 100644 --- a/lorrycontroller/readconf.py +++ b/lorrycontroller/readconf.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2016 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -69,7 +69,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', 'troves'): + elif section['type'] in ('trove', 'troves', 'gitlab'): self.add_trove(statedb, section) trovehost = section['trovehost'] if trovehost in troves_to_remove: @@ -286,6 +286,10 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): username = auth.get('username') password = auth.get('password') + gitlab_token = None + if section['type'] == 'gitlab': + gitlab_token = section['private-token'] + statedb.add_trove( trovehost=section['trovehost'], protocol=section['protocol'], @@ -296,7 +300,8 @@ class ReadConfiguration(lorrycontroller.LorryControllerRoute): 'lorry-timeout', self.DEFAULT_LORRY_TIMEOUT), ls_interval=section['ls-interval'], prefixmap=json.dumps(section['prefixmap']), - ignore=json.dumps(section.get('ignore', []))) + ignore=json.dumps(section.get('ignore', [])), + gitlab_token=gitlab_token) class ValidationError(Exception): @@ -320,6 +325,8 @@ class LorryControllerConfValidator(object): self._check_troves_section(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']) @@ -338,6 +345,11 @@ class LorryControllerConfValidator(object): if type(item) is not dict: raise ValidationError('all items must be dicts') + def _check_gitlab_section(self, section): + # gitlab section inherits trove configurations, perform the same checks. + self._check_troves_section(section) + self._check_has_required_fields(section, ['private-token']) + def _check_troves_section(self, section): self._check_has_required_fields( section, |