Skip to content

Commit 93b0788

Browse files
author
Vladimir Kotal
committed
perform a little bit more configuration checks
1 parent 0817a68 commit 93b0788

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tools/sync/mirror.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@
103103
else:
104104
config = {}
105105

106+
GLOBAL_TUNABLES = ['hookdir', 'proxy', 'logdir', 'commands', 'projects',
107+
HOOK_TIMEOUT_PROPERTY, CMD_TIMEOUT_PROPERTY]
108+
for key in config.keys():
109+
if key not in GLOBAL_TUNABLES:
110+
logger.error("uknown global configuration option '{}'"
111+
.format(key))
112+
sys.exit(1)
113+
106114
# Make sure the log directory exists.
107115
logdir = config.get("logdir")
108116
if logdir:
@@ -169,6 +177,16 @@
169177
logger.debug("Project '{}' has specific (non-default) config".
170178
format(args.project))
171179

180+
# Quick sanity check.
181+
KNOWN_PROJECT_TUNABLES = ['disabled', CMD_TIMEOUT_PROPERTY,
182+
HOOK_TIMEOUT_PROPERTY, 'proxy',
183+
'ignored_repos', 'hooks']
184+
for key in project_config.keys():
185+
if key not in KNOWN_PROJECT_TUNABLES:
186+
logger.error("uknown project configuration option '{}' "
187+
"for project {}".format(key, args.project))
188+
sys.exit(1)
189+
172190
project_command_timeout = get_int(logger, "command timeout for "
173191
"project {}".format(args.project),
174192
project_config.
@@ -187,8 +205,12 @@
187205
logger.debug("Project hook timeout = {}".
188206
format(hook_timeout))
189207

190-
if project_config.get('ignored_repos'):
191-
ignored_repos = project_config.get('ignored_repos')
208+
ignored_repos = project_config.get('ignored_repos')
209+
if ignored_repos:
210+
if type(ignored_repos) is not list:
211+
logger.error("ignored_repos for project {} is not a list".
212+
format(args.project))
213+
sys.exit(1)
192214
logger.debug("has ignored repositories: {}".
193215
format(ignored_repos))
194216

0 commit comments

Comments
 (0)