2021-01-30 15:52:48 +00:00
|
|
|
from ansible.parsing.yaml.objects import AnsibleMapping
|
|
|
|
|
2024-01-25 20:09:05 +00:00
|
|
|
from ansiblelater.rule import RuleBase
|
2021-01-30 15:52:48 +00:00
|
|
|
|
|
|
|
|
2024-01-25 20:09:05 +00:00
|
|
|
class CheckScmInSrc(RuleBase):
|
2021-01-30 15:52:48 +00:00
|
|
|
sid = "ANSIBLE0005"
|
|
|
|
description = "Use `scm:` key rather than `src: scm+url`"
|
|
|
|
helptext = "usage of `src: scm+url` not recommended"
|
|
|
|
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 (
|
2023-11-10 13:50:48 +00:00
|
|
|
isinstance(role, AnsibleMapping)
|
|
|
|
and bool(role.get("src"))
|
2023-05-29 12:51:52 +00:00
|
|
|
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)
|