Fix time machine config validator on old-style config
Existing config won't have the keys defined, so make sure we skip in that case (and just use the defaults)
This commit is contained in:
parent
66b98e5380
commit
4ea4ee3aa4
2 changed files with 13 additions and 3 deletions
|
@ -10,15 +10,19 @@ class TimeMachineValidator(BaseValidator):
|
|||
|
||||
@classmethod
|
||||
def validate(cls, config, user, user_password):
|
||||
if not 'DEFAULT_TAG_EXPIRATION' in config:
|
||||
# Old style config
|
||||
return
|
||||
|
||||
try:
|
||||
convert_to_timedelta(config['DEFAULT_TAG_EXPIRATION']).total_seconds()
|
||||
except ValueError as ve:
|
||||
raise ConfigValidationException('Invalid default expiration: %s' % ve.message)
|
||||
|
||||
if not config['DEFAULT_TAG_EXPIRATION'] in config['TAG_EXPIRATION_OPTIONS']:
|
||||
if not config['DEFAULT_TAG_EXPIRATION'] in config.get('TAG_EXPIRATION_OPTIONS', []):
|
||||
raise ConfigValidationException('Default expiration must be in expiration options set')
|
||||
|
||||
for ts in config['TAG_EXPIRATION_OPTIONS']:
|
||||
for ts in config.get('TAG_EXPIRATION_OPTIONS', []):
|
||||
try:
|
||||
convert_to_timedelta(ts)
|
||||
except ValueError as ve:
|
||||
|
|
Reference in a new issue