ansible-later/ansiblelater/rules/rolefiles.py

30 lines
950 B
Python
Raw Normal View History

2018-12-19 10:19:07 +00:00
from nested_lookup import nested_lookup
2019-04-02 14:34:03 +00:00
from ansiblelater.command.review import Error, Result
2018-12-19 10:19:07 +00:00
from ansiblelater.utils.rulehelper import get_raw_yaml, get_tasks
def check_meta_main(candidate, settings):
content, errors = get_raw_yaml(candidate, settings)
keys = ["author", "description", "min_ansible_version", "platforms", "dependencies"]
description = "file should contain '%s' key"
if not errors:
for key in keys:
if not nested_lookup(key, content):
errors.append(Error(None, description % (key)))
return Result(candidate.path, errors)
def check_scm_in_src(candidate, settings):
roles, errors = get_tasks(candidate, settings)
description = "usage of src: scm+url not recommended"
if not errors:
for role in roles:
2019-04-04 14:06:18 +00:00
if "+" in role.get("src"):
errors.append(Error(role["__line__"], description))
2018-12-19 10:19:07 +00:00
return Result(candidate.path, errors)