summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-04-22 14:59:58 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-04-22 14:59:58 +0000
commitd50b6551ee8674d354239c4d570dac0204fd6136 (patch)
tree9ce36a33e83a3e3432fb9e9d0430d79d488812d3
parent2bc37426f5caf3a257fa8637f3fd10e60590ddb2 (diff)
downloadlorry-controller-d50b6551ee8674d354239c4d570dac0204fd6136.tar.gz
Validate protocol field in lorry-controller.conf
-rw-r--r--lorrycontroller/readconf.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index b455583..9ea8173 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -316,8 +316,16 @@ class LorryControllerConfValidator(object):
self._check_has_required_fields(
section,
['trovehost', 'protocol', 'interval', 'ls-interval', 'prefixmap'])
+ self._check_protocol(section)
self._check_prefixmap(section)
+ def _check_protocol(self, section):
+ valid = ('ssh', 'http', 'https')
+ if section['protocol'] not in valid:
+ raise ValidationError(
+ 'protocol field has value "%s", but valid ones are %s' %
+ (section['protocol'], ', '.join(valid)))
+
def _check_prefixmap(self, section):
# FIXME: We should be checking the prefixmap for things like
# mapping to a prefix that starts with the local Trove ID, but