Botmeta validate path macros (#48980)

BOTMETA validation - use path macros

Rather than hard coding the list of path macros, read them directly from
BOTMETA
pull/48990/head
John R Barker 6 years ago committed by GitHub
parent 97e2fa4953
commit e7da4975cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,20 +64,18 @@ def main():
if botmeta_support != 'core':
print('%s:%d:%d: .github/BOTMETA.yml MUST be support: core' % (path, 0, 0))
# We have two macros to define locations, ensure they haven't been removed
module_utils_path = botmeta.get('macros', {}).get('module_utils', '')
modules_path = botmeta.get('macros', {}).get('modules', '')
if module_utils_path != 'lib/ansible/module_utils':
print('%s:%d:%d: [macros][module_utils] has been changed or removed' % (path, 0, 0))
if modules_path != 'lib/ansible/modules':
print('%s:%d:%d: [macros][modules] has been changed or removed' % (path, 0, 0))
# See if all `files:` are valid
# Find all path (none-team) macros so we can substitute them
macros = botmeta.get('macros', {})
path_macros = []
for macro in macros:
if macro.startswith('team_'):
continue
path_macros.append(macro)
# Ensure all `files` correspond to a file
for file in botmeta['files']:
file = file.replace('$module_utils', module_utils_path)
file = file.replace('$modules', modules_path)
for macro in path_macros:
file = file.replace('$' + macro, botmeta.get('macros', {}).get(macro, ''))
if not os.path.exists(file):
# Not a file or directory, though maybe the prefix to one?
# https://github.com/ansible/ansibullbot/pull/1023
@ -91,4 +89,4 @@ if __name__ == '__main__':
# Possible future work
# * Schema for `macros:` - currently ignored due to team_ansible
# * Ensure that all $teams mention in `files:` exist in `$macros`
# * Validate GitHub names - possibly expensive lookup needed
# * Validate GitHub names - possibly expensive lookup needed - No should be validated when module is added - gundalow

Loading…
Cancel
Save