Skip to content

Commit

Permalink
Generalize processing of tasks lintable kind (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Feb 23, 2021
1 parent 08264af commit f14b87b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ def main():

FileType = Literal[
"playbook",
"pre_tasks",
"post_tasks",
"meta", # role meta
"tasks",
"handlers",
"tasks", # includes pre_tasks, post_tasks
"handlers", # very similar to tasks but with some specificts
# https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-roles-and-collections-from-the-same-requirements-yml-file
"requirements",
"role", # that is a folder!
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/skip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _append_skipped_rules(pyyaml_data: Sequence[Any], lintable: Lintable) -> Seq
if lintable.kind in ('tasks', 'handlers'):
ruamel_task_blocks = ruamel_data
pyyaml_task_blocks = pyyaml_data
elif lintable.kind in ('playbook', 'pre_tasks', 'post_tasks'):
elif lintable.kind == 'playbook':
try:
pyyaml_task_blocks = _get_task_blocks_from_playbook(pyyaml_data)
ruamel_task_blocks = _get_task_blocks_from_playbook(ruamel_data)
Expand Down
5 changes: 2 additions & 3 deletions src/ansiblelint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,15 +468,14 @@ def _look_for_role_files(basedir: str, role: str, main='main') -> List[Lintable]

results = []

for kind in ['tasks', 'meta', 'handlers']:
for kind in ['tasks', 'meta', 'handlers', 'vars', 'defaults']:
current_path = os.path.join(role_path, kind)
for folder, subdirs, files in os.walk(current_path):
for file in files:
file_ignorecase = file.lower()
if file_ignorecase.endswith(('.yml', '.yaml')):
thpath = os.path.join(folder, file)
# TODO(ssbarnea): Find correct way to pass kind: FileType
results.append(Lintable(thpath, kind=kind)) # type: ignore
results.append(Lintable(thpath))

return results

Expand Down

0 comments on commit f14b87b

Please sign in to comment.