Basic validation for gerritbot/channels.yaml
Recently a change merged that had not branches line and gerritbot refused to start again. This could have been avoided by validation of the file. Test some basic validation of the yaml file to avoid breakage. Change-Id: I2dc4a28aeac07d3fc73d3954d8fbe8f2448334e5
This commit is contained in:
parent
efe623ac28
commit
0b4b988d9f
@ -33,7 +33,27 @@ def access_gerrit_check():
|
||||
|
||||
gerrit_config = yaml.load(open('gerritbot/channels.yaml'))
|
||||
|
||||
print("Checking that all channels in gerritbot are also in accessbot")
|
||||
print("Basic check of gerritbot/channels.yaml")
|
||||
REQUIRED_ENTRIES=("branches", "events", "projects")
|
||||
VALID_EVENTS=("change-merged", "patchset-created", "x-vrif-minus-2")
|
||||
for channel in gerrit_config:
|
||||
for entry in REQUIRED_ENTRIES:
|
||||
if entry not in gerrit_config[channel]:
|
||||
print(" Required entry '%s' not specified for channel '%s'"
|
||||
% (entry, channel))
|
||||
errors = True
|
||||
elif not gerrit_config[channel][entry]:
|
||||
print(" Entry '%s' has no content for channel '%s'"
|
||||
% (entry, channel))
|
||||
errors = True
|
||||
|
||||
for event in gerrit_config[channel]['events']:
|
||||
if event not in VALID_EVENTS:
|
||||
print(" Event '%s' for channel '%s' is invalid"
|
||||
% (event, channel))
|
||||
errors = True
|
||||
|
||||
print("\nChecking that all channels in gerritbot are also in accessbot")
|
||||
for channel in gerrit_config:
|
||||
if channel not in access_channel_set:
|
||||
print(" %s is missing from accessbot" % channel)
|
||||
|
Loading…
Reference in New Issue
Block a user