mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-23 05:10:40 +00:00
28 lines
1006 B
Python
28 lines
1006 B
Python
from nested_lookup import nested_lookup
|
|
|
|
from ansiblelater.standard import StandardBase
|
|
|
|
|
|
class CheckMetaMain(StandardBase):
|
|
|
|
sid = "ANSIBLE0002"
|
|
description = "Roles must contain suitable meta/main.yml"
|
|
helptext = "file should contain `{key}` key"
|
|
version = "0.1"
|
|
types = ["meta"]
|
|
|
|
def check(self, candidate, settings):
|
|
content, errors = self.get_raw_yaml(candidate, settings)
|
|
keys = ["author", "description", "min_ansible_version", "platforms", "dependencies"]
|
|
|
|
if not errors:
|
|
has_galaxy_info = (isinstance(content, dict) and "galaxy_info" in content.keys())
|
|
if not has_galaxy_info:
|
|
errors.append(self.Error(None, self.helptext.format(key="galaxy_info")))
|
|
|
|
for key in keys:
|
|
if has_galaxy_info and not nested_lookup(key, content.get("galaxy_info", {})):
|
|
errors.append(self.Error(None, self.helptext.format(key=key)))
|
|
|
|
return self.Result(candidate.path, errors)
|