2021-01-30 15:52:48 +00:00
|
|
|
from ansible.parsing.yaml.objects import AnsibleMapping
|
|
|
|
|
|
|
|
from ansiblelater.standard import StandardBase
|
|
|
|
|
|
|
|
|
|
|
|
class CheckScmInSrc(StandardBase):
|
|
|
|
|
|
|
|
sid = "ANSIBLE0005"
|
|
|
|
description = "Use `scm:` key rather than `src: scm+url`"
|
|
|
|
helptext = "usage of `src: scm+url` not recommended"
|
|
|
|
version = "0.1"
|
|
|
|
types = ["rolesfile"]
|
|
|
|
|
|
|
|
def check(self, candidate, settings):
|
|
|
|
roles, errors = self.get_tasks(candidate, settings)
|
|
|
|
|
|
|
|
if not errors:
|
|
|
|
for role in roles:
|
2023-05-29 12:51:52 +00:00
|
|
|
if (
|
|
|
|
isinstance(role, AnsibleMapping) and bool(role.get("src"))
|
|
|
|
and "+" in role.get("src")
|
|
|
|
):
|
2023-02-10 07:51:17 +00:00
|
|
|
errors.append(self.Error(role["__line__"], self.helptext))
|
2021-01-30 15:52:48 +00:00
|
|
|
|
|
|
|
return self.Result(candidate.path, errors)
|