mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-13 00:30:39 +00:00
parent
f3646adf15
commit
8834d1e1d8
@ -191,7 +191,7 @@ class Candidate:
|
||||
if sid:
|
||||
standard_id = f"[{sid}] "
|
||||
|
||||
return standard_id
|
||||
return standard_id # noqa
|
||||
|
||||
def __repr__(self):
|
||||
return f"{type(self).__name__} ({self.path})"
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckBecomeUser(StandardBase):
|
||||
description = "Become should be combined with become_user"
|
||||
helptext = "the task has `become` enabled but `become_user` is missing"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
from ansiblelater.utils import count_spaces
|
||||
@ -11,9 +10,7 @@ class CheckBracesSpaces(StandardBase):
|
||||
description = "YAML should use consistent number of spaces around variables"
|
||||
helptext = "no suitable numbers of spaces (min: {min} max: {max})"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -18,8 +18,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -29,7 +27,7 @@ class CheckChangedInWhen(StandardBase):
|
||||
description = "Use handlers instead of `when: changed`"
|
||||
helptext = "tasks using `when: result.changed` setting are effectively acting as a handler"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -12,7 +10,7 @@ class CheckCommandHasChanges(StandardBase):
|
||||
"idempotent while using controls like `creates`, `removes` or `when`"
|
||||
)
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task"]
|
||||
types = ["playbook", "task"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -19,7 +19,6 @@
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -30,7 +29,7 @@ class CheckCommandInsteadOfArgument(StandardBase):
|
||||
description = "Commands should not be used in place of module arguments"
|
||||
helptext = "{exec} used in place of file modules argument {arg}"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import os
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,7 +9,7 @@ class CheckCommandInsteadOfModule(StandardBase):
|
||||
description = "Commands should not be used in place of modules"
|
||||
helptext = "{exec} command used in place of {module} module"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.candidate import Template
|
||||
from ansiblelater.standard import StandardBase
|
||||
@ -11,7 +10,7 @@ class CheckCompareToEmptyString(StandardBase):
|
||||
description = "Don't compare to empty string \"\""
|
||||
helptext = ("use `when: var` rather than `when: var !=` (or conversely `when: not var`)")
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler", "template"]
|
||||
types = ["playbook", "task", "handler", "template"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.candidate import Template
|
||||
from ansiblelater.standard import StandardBase
|
||||
@ -11,7 +10,7 @@ class CheckCompareToLiteralBool(StandardBase):
|
||||
description = "Don't compare to True or False"
|
||||
helptext = ("use `when: var` rather than `when: var == True` (or conversely `when: not var`)")
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckDeprecated(StandardBase):
|
||||
description = "Deprecated features should not be used"
|
||||
helptext = "'{old}' is deprecated and should not be used anymore. Use '{new}' instead."
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings, full=True)
|
||||
|
@ -19,7 +19,6 @@
|
||||
# THE SOFTWARE.
|
||||
|
||||
import os
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
from ansiblelater.utils import has_glob, has_jinja
|
||||
@ -34,7 +33,7 @@ class CheckDeprecatedBareVars(StandardBase):
|
||||
"or be converted to a list"
|
||||
)
|
||||
version = "0.3"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, self.errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -18,7 +18,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -32,9 +31,9 @@ class CheckFilePermissionMissing(StandardBase):
|
||||
"to avoid unexpected file permissions"
|
||||
)
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
_modules: ClassVar[dict] = {
|
||||
_modules = {
|
||||
"archive",
|
||||
"assemble",
|
||||
"copy",
|
||||
@ -42,7 +41,7 @@ class CheckFilePermissionMissing(StandardBase):
|
||||
"replace",
|
||||
"template",
|
||||
}
|
||||
_create_modules: ClassVar[dict[str, bool]] = {
|
||||
_create_modules = {
|
||||
"blockinfile": False,
|
||||
"htpasswd": True,
|
||||
"ini_file": True,
|
||||
|
@ -18,8 +18,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -29,7 +27,7 @@ class CheckFilePermissionOctal(StandardBase):
|
||||
description = "Octal file permissions must contain leading zero or be a string"
|
||||
helptext = "numeric file permissions without leading zero can behave in unexpected ways"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,8 +9,7 @@ class CheckFilterSeparation(StandardBase):
|
||||
description = "Jinja2 filters should be separated with spaces"
|
||||
helptext = "no suitable numbers of spaces (required: 1)"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]
|
||||
] = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -18,8 +18,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -29,7 +27,7 @@ class CheckGitHasVersion(StandardBase):
|
||||
description = "Git checkouts should use explicit version"
|
||||
helptext = "git checkouts should point to an explicit commit or tag, not `latest`"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckInstallUseLatest(StandardBase):
|
||||
description = "Package installs should use present, not latest"
|
||||
helptext = "package installs should use `state=present` with or without a version"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,8 +9,7 @@ class CheckLiteralBoolFormat(StandardBase):
|
||||
description = "Literal bools should be consistent"
|
||||
helptext = "literal bools should be written as `{bools}`"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]
|
||||
] = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,7 +1,5 @@
|
||||
# Copyright (c) 2016, Tsukinowa Inc. <info@tsukinowa.jp>
|
||||
# Copyright (c) 2018, Ansible Project
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -11,7 +9,7 @@ class CheckLocalAction(StandardBase):
|
||||
description = "Don't use local_action"
|
||||
helptext = ("`delegate_to: localhost` should be used instead of `local_action`")
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,6 +1,4 @@
|
||||
# Copyright (c) 2018, Ansible Project
|
||||
from typing import ClassVar
|
||||
|
||||
from nested_lookup import nested_lookup
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
@ -12,7 +10,7 @@ class CheckMetaChangeFromDefault(StandardBase):
|
||||
description = "Roles meta/main.yml default values should be changed"
|
||||
helptext = "meta/main.yml default values should be changed for: `{field}`"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["meta"]
|
||||
types = ["meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
content, errors = self.get_raw_yaml(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from nested_lookup import nested_lookup
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
@ -11,7 +9,7 @@ class CheckMetaMain(StandardBase):
|
||||
description = "Roles must contain suitable meta/main.yml"
|
||||
helptext = "file should contain `{key}` key"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["meta"]
|
||||
types = ["meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
content, errors = self.get_raw_yaml(candidate, settings)
|
||||
|
@ -1,5 +1,4 @@
|
||||
from collections import defaultdict
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,7 +9,7 @@ class CheckNameFormat(StandardBase):
|
||||
description = "Name of tasks and handlers must be formatted"
|
||||
helptext = "name '{name}' should start with uppercase"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckNamedTask(StandardBase):
|
||||
description = "Tasks and handlers must be named"
|
||||
helptext = "module '{module}' used without or empty `name` attribute"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckNativeYaml(StandardBase):
|
||||
description = "Use YAML format for tasks and handlers rather than key=value"
|
||||
helptext = "task arguments appear to be in key value rather than YAML format"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_action_tasks(candidate, settings)
|
||||
|
@ -20,7 +20,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
import re
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -34,8 +33,7 @@ class CheckNestedJinja(StandardBase):
|
||||
"like `{{ list_one + {{ list_two | max }} }}`"
|
||||
)
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]
|
||||
] = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,7 +1,5 @@
|
||||
# Copyright (c) 2016, Tsukinowa Inc. <info@tsukinowa.jp>
|
||||
# Copyright (c) 2018, Ansible Project
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -11,7 +9,7 @@ class CheckRelativeRolePaths(StandardBase):
|
||||
description = "Don't use a relative path in a role"
|
||||
helptext = "`copy` and `template` modules don't need relative path for `src`"
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansible.parsing.yaml.objects import AnsibleMapping
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
@ -11,7 +9,7 @@ class CheckScmInSrc(StandardBase):
|
||||
description = "Use `scm:` key rather than `src: scm+url`"
|
||||
helptext = "usage of `src: scm+url` not recommended"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["rolesfile"]
|
||||
types = ["rolesfile"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
roles, errors = self.get_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckShellInsteadCommand(StandardBase):
|
||||
description = "Shell should only be used when essential"
|
||||
helptext = "shell should only be used when piping, redirecting or chaining commands"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -11,7 +10,7 @@ class CheckTaskSeparation(StandardBase):
|
||||
description = "Single tasks should be separated by empty line"
|
||||
helptext = "missing task separation (required: 1 empty line)"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = defaultdict(dict)
|
||||
|
@ -1,5 +1,4 @@
|
||||
from collections import defaultdict
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,7 +9,7 @@ class CheckUniqueNamedTask(StandardBase):
|
||||
description = "Tasks and handlers must be uniquely named within a single file"
|
||||
helptext = "name '{name}' appears multiple times"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,8 +6,7 @@ class CheckVersion(StandardBase):
|
||||
sid = "ANSIBLE9998"
|
||||
description = "Standards version should be pinned"
|
||||
helptext = "Standards version not set. Using latest standards version {version}"
|
||||
types: ClassVar[list[str]
|
||||
] = ["task", "handler", "rolevars", "meta", "template", "file", "playbook"]
|
||||
types = ["task", "handler", "rolevars", "meta", "template", "file", "playbook"]
|
||||
|
||||
def check(self, candidate, settings): # noqa
|
||||
errors = []
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -12,7 +10,7 @@ class CheckWhenFormat(StandardBase):
|
||||
"should be removed from variable(s)"
|
||||
)
|
||||
version = "0.2"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlColons(StandardBase):
|
||||
sid = "LINT0005"
|
||||
description = "YAML should use consistent number of spaces around colons"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{colons: {settings['yamllint']['colons']}}}"
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlDocumentEnd(StandardBase):
|
||||
sid = "LINT0009"
|
||||
description = "YAML should contain document end marker"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{document-end: {settings['yamllint']['document-end']}}}"
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlDocumentStart(StandardBase):
|
||||
sid = "LINT0004"
|
||||
description = "YAML should contain document start marker"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{document-start: {settings['yamllint']['document-start']}}}"
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlEmptyLines(StandardBase):
|
||||
sid = "LINT0001"
|
||||
description = "YAML should not contain unnecessarily empty lines"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{empty-lines: {settings['yamllint']['empty-lines']}}}"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import os
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
@ -10,7 +9,7 @@ class CheckYamlFile(StandardBase):
|
||||
description = "Roles file should be in yaml format"
|
||||
helptext = "file does not have a .yml extension"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler"]
|
||||
types = ["playbook", "task", "handler"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
errors = []
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -9,7 +7,7 @@ class CheckYamlHasContent(StandardBase):
|
||||
description = "Files should contain useful content"
|
||||
helptext = "the file appears to have no useful content"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = ["playbook", "task", "handler", "rolevars", "defaults", "meta"]
|
||||
types = ["playbook", "task", "handler", "rolevars", "defaults", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
yamllines, errors = self.get_normalized_yaml(candidate, settings)
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlHyphens(StandardBase):
|
||||
sid = "LINT0003"
|
||||
description = "YAML should use consistent number of spaces after hyphens"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{hyphens: {settings['yamllint']['hyphens']}}}"
|
||||
|
@ -1,5 +1,3 @@
|
||||
from typing import ClassVar
|
||||
|
||||
from ansiblelater.standard import StandardBase
|
||||
|
||||
|
||||
@ -8,9 +6,7 @@ class CheckYamlIndent(StandardBase):
|
||||
sid = "LINT0002"
|
||||
description = "YAML should not contain unnecessarily empty lines"
|
||||
version = "0.1"
|
||||
types: ClassVar[list[str]] = [
|
||||
"playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"
|
||||
]
|
||||
types = ["playbook", "task", "handler", "rolevars", "hostvars", "groupvars", "meta"]
|
||||
|
||||
def check(self, candidate, settings):
|
||||
options = f"rules: {{document-start: {settings['yamllint']['document-start']}}}"
|
||||
|
@ -304,7 +304,7 @@ class StandardBase(metaclass=StandardExtendedMeta):
|
||||
return "\n".join([f"{self.candidate}:{error}" for error in self.errors])
|
||||
|
||||
|
||||
class StandardLoader:
|
||||
class StandardLoader():
|
||||
|
||||
def __init__(self, source):
|
||||
self.rules = []
|
||||
|
@ -5,7 +5,6 @@ import re
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from distutils.version import LooseVersion
|
||||
from typing import ClassVar
|
||||
|
||||
import yaml
|
||||
|
||||
@ -115,7 +114,7 @@ def sysexit_with_message(msg, code=1):
|
||||
class Singleton(type):
|
||||
"""Meta singleton class."""
|
||||
|
||||
_instances: ClassVar[dict] = {}
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
|
@ -209,10 +209,11 @@ def template(basedir, value, variables, fail_on_undefined=False, **kwargs):
|
||||
# Hack to skip the following exception when using to_json filter on a variable.
|
||||
# I guess the filter doesn't like empty vars...
|
||||
with suppress(AnsibleError, ValueError):
|
||||
return ansible_template(
|
||||
value = ansible_template(
|
||||
os.path.abspath(basedir), value, variables,
|
||||
**dict(kwargs, fail_on_undefined=fail_on_undefined)
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
def play_children(basedir, item, parent_type):
|
||||
@ -372,7 +373,8 @@ def rolename(filepath):
|
||||
if idx < 0:
|
||||
return ""
|
||||
role = filepath[idx + 6:]
|
||||
return role[:role.find("/")]
|
||||
role = role[:role.find("/")]
|
||||
return role
|
||||
|
||||
|
||||
def _kv_to_dict(v):
|
||||
|
Loading…
Reference in New Issue
Block a user