config: Allow empty config files

Change-Id: Ic010e06220421df00405c5b6f5ad2e83514b6dcd
This commit is contained in:
Pau Espin 2020-06-15 13:57:54 +02:00
parent 683d196532
commit e66e3aebb4
2 changed files with 4 additions and 2 deletions

View File

@ -137,6 +137,8 @@ def _get_main_config():
global MAIN_CONFIG
if MAIN_CONFIG is None:
cfg = read(_get_main_config_path(), MAIN_CONFIG_SCHEMA)
if cfg is None:
cfg = {}
MAIN_CONFIG = {
CFG_STATE_DIR: DF_CFG_STATE_DIR,
CFG_SUITES_DIR: DF_CFG_SUITES_DIR,
@ -195,7 +197,7 @@ def read(path, validation_schema=None, if_missing_return=False):
with open(path, 'r') as f:
config = yaml.safe_load(f)
config = _standardize(config)
if validation_schema:
if config and validation_schema:
schema.validate(config, validation_schema)
return config

View File

@ -54,7 +54,7 @@ class ResourcesPool(log.Origin):
self.read_conf()
def read_conf(self):
self.all_resources = Resources(config.read(self.config_path, schema.get_resources_schema()))
self.all_resources = Resources(config.read(self.config_path, schema.get_resources_schema()) or {})
self.all_resources.set_hashes()
def reserve(self, origin, want, modifiers):