Gerrit ACLs: Check for valid keys

Add check for valid keys to find obvious typos in keys.

Fix the one error found in openstack.config.

Change-Id: I6a2af22db0b9425372e66dca93498a33a07275e9
This commit is contained in:
Andreas Jaeger 2016-07-07 08:43:49 +02:00 committed by Andreas Jaeger
parent 5633dab207
commit 4e9f7cf97e
2 changed files with 28 additions and 1 deletions

View File

@ -1,5 +1,5 @@
[access "refs/for/refs/*"]
exclsiveGroupPermissions = Push
exclusiveGroupPermissions = Push
push = group Release Managers
[access "refs/heads/*"]

View File

@ -45,6 +45,29 @@ def tokens(data):
acl = {}
out = ''
valid_keys = {'abandon',
'access',
'copyAllScoresOnTrivialRebase',
'create',
'defaultValue',
'exclusiveGroupPermissions',
'forgeAuthor',
'forgeCommitter',
'function',
'label-Code-Review',
'label-Rollcall-Vote',
'label-Workflow',
'label-Verified',
'mergeContent',
'push',
'pushMerge',
'pushSignedTag',
'requireChangeId',
'requireContributorAgreement',
'state',
'value'
}
if '0' in transformations or not transformations:
dry_run = True
else:
@ -65,6 +88,10 @@ for line in aclfd:
# key=value lines
elif '=' in line:
acl[section].append(line)
# Check for valid keys
key = line.split('=')[0].strip()
if key not in valid_keys:
raise Exception('Unrecognized key in line: "%s"' % line)
# WTF
else:
raise Exception('Unrecognized line: "%s"' % line)