Add config validation on startup (#2903)
* WIP * Finish schema Add three sections: security scanning, bittorrent support and feature flags.
This commit is contained in:
parent
1882545c69
commit
c383ac1f9d
2 changed files with 632 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
|||
import logging
|
||||
import yaml
|
||||
|
||||
|
||||
from jsonschema import validate, ValidationError
|
||||
|
||||
|
||||
from util.config.schema import CONFIG_SCHEMA
|
||||
from util.license import LICENSE_FILENAME, LicenseDecodeError, decode_license
|
||||
|
||||
|
||||
|
@ -31,6 +36,15 @@ def import_yaml(config_obj, config_file):
|
|||
if key.isupper():
|
||||
config_obj[key] = c[key]
|
||||
|
||||
if config_obj.get('SETUP_COMPLETE', True):
|
||||
try:
|
||||
validate(config_obj, CONFIG_SCHEMA)
|
||||
except ValidationError:
|
||||
# TODO: Change this into a real error
|
||||
logger.exception('Could not validate config schema')
|
||||
else:
|
||||
logger.debug('Skipping config schema validation because setup is not complete')
|
||||
|
||||
return config_obj
|
||||
|
||||
|
||||
|
@ -109,7 +123,7 @@ class BaseProvider(object):
|
|||
indicating that this container requires a restart.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def get_volume_path(self, directory, filename):
|
||||
""" Helper for constructing file paths, which may differ between providers. For example,
|
||||
kubernetes can't have subfolders in configmaps """
|
||||
|
|
Reference in a new issue