2021-01-30 15:52:48 +00:00
|
|
|
import os
|
2023-06-28 06:19:08 +00:00
|
|
|
from typing import ClassVar
|
2021-01-30 15:52:48 +00:00
|
|
|
|
|
|
|
from ansiblelater.standard import StandardBase
|
|
|
|
|
|
|
|
|
|
|
|
class CheckYamlFile(StandardBase):
|
|
|
|
|
|
|
|
sid = "LINT0006"
|
|
|
|
description = "Roles file should be in yaml format"
|
|
|
|
helptext = "file does not have a .yml extension"
|
|
|
|
version = "0.1"
|
2023-06-28 06:19:08 +00:00
|
|
|
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
2021-01-30 15:52:48 +00:00
|
|
|
|
|
|
|
def check(self, candidate, settings):
|
|
|
|
errors = []
|
|
|
|
extensions = [".yml", ".yaml"]
|
|
|
|
|
|
|
|
if os.path.isfile(candidate.path) and os.path.splitext(candidate.path)[1] in extensions:
|
|
|
|
content, errors = self.get_raw_yaml(candidate, settings)
|
|
|
|
else:
|
|
|
|
errors.append(self.Error(None, self.helptext))
|
|
|
|
|
|
|
|
return self.Result(candidate.path, errors)
|