diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-05-07 21:40:01 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-06-01 15:31:19 +0100 |
commit | 4cce11af4ca0491b3da92321ddc44169909a6c26 (patch) | |
tree | 22e2b224caf24837529e5c57720d0b2731560d7c /lorry-controller-webapp | |
parent | d19a2d783d8567b8c482b01e3e6704403f3f43c5 (diff) | |
download | lorry-controller-4cce11af4ca0491b3da92321ddc44169909a6c26.tar.gz |
Move Downstream Host type-specific code into modules
* Introduce hosts module and DownstreamHost abstract base class
* Define a subclass of this for each Downstream Host type
* Define a name-type map for these in the lorrycontroller package
* Use these classes to replace type-specific code elsewhere
Related to #5.
Diffstat (limited to 'lorry-controller-webapp')
-rwxr-xr-x | lorry-controller-webapp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp index 9e3a310..6fc827e 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -131,17 +131,21 @@ class WEBAPP(cliapp.Application): self.settings.choice( ['downstream-host-type', 'git-server-type'], - ['gitano', 'gerrit', 'gitlab', 'local'], + # Default is the first choice, and must be 'gitano' for backward + # compatibility + ['gitano'] + + sorted(host_type + for host_type in lorrycontroller.downstream_types.keys() + if host_type != 'gitano'), 'what API the Downstream Host speaks') - self.settings.string( - ['gitlab-private-token'], - 'private token for GitLab API access') - self.settings.boolean( ['publish-failures'], 'make the status page show failure logs from lorry') + for downstream_type in lorrycontroller.downstream_types.values(): + downstream_type.add_app_settings(self.settings) + def find_routes(self): '''Return all classes that are API routes. @@ -166,11 +170,8 @@ class WEBAPP(cliapp.Application): def process_args(self, args): self.settings.require('statedb') - if (self.settings['git-server-type'] == 'gitlab' and - not self.settings['gitlab-private-token']): - logging.error('A private token must be provided to create ' - 'repositories on a GitLab instance.') - self.settings.require('gitlab-private-token') + lorrycontroller.downstream_types[self.settings['git-server-type']] \ + .check_app_settings(self.settings) self.setup_proxy() |