Check unsupported TOP_LEVEL_KEYS

Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
This commit is contained in:
Andras Mitzki 2019-03-25 15:52:10 +01:00
parent da00fa98f9
commit 04c581dedc

View file

@ -162,6 +162,7 @@ def _non_cloned_repository_hooks(repo_config, store, root_config):
def _cloned_repository_hooks(repo_config, store, root_config): def _cloned_repository_hooks(repo_config, store, root_config):
_check_extra_top_level_keys(repo_config)
repo, rev = repo_config['repo'], repo_config['rev'] repo, rev = repo_config['repo'], repo_config['rev']
manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE) manifest_path = os.path.join(store.clone(repo, rev), C.MANIFEST_FILE)
by_id = {hook['id']: hook for hook in load_manifest(manifest_path)} by_id = {hook['id']: hook for hook in load_manifest(manifest_path)}
@ -190,6 +191,21 @@ def _cloned_repository_hooks(repo_config, store, root_config):
) )
_TOP_LEVEL_KEYS = ('repo', 'rev', 'hooks')
def _check_extra_top_level_keys(repo_config):
extra_top_level_keys = set(dict(repo_config).keys()) - set(_TOP_LEVEL_KEYS)
if extra_top_level_keys:
logger.warning(
'Unexpected top level keys present: {}, only supported'
'top level keys: {}'.format(
extra_top_level_keys,
_TOP_LEVEL_KEYS,
),
)
def _repository_hooks(repo_config, store, root_config): def _repository_hooks(repo_config, store, root_config):
if repo_config['repo'] in {LOCAL, META}: if repo_config['repo'] in {LOCAL, META}:
return _non_cloned_repository_hooks(repo_config, store, root_config) return _non_cloned_repository_hooks(repo_config, store, root_config)