Skip to content

Commit

Permalink
Update name[casing] transform function to change task name for 'liste…
Browse files Browse the repository at this point in the history
…n' handler arg
  • Loading branch information
audgirka committed Feb 26, 2024
1 parent 072a5c5 commit 335088f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/playbooks/name-case.transformed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
- name: My handler
ansible.builtin.debug:
msg: I never run :(

- name: Test task for listen
ansible.builtin.debug:
msg: I never run :(
listen: My handler
5 changes: 5 additions & 0 deletions examples/playbooks/name-case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
- name: my handler
ansible.builtin.debug:
msg: I never run :(

- name: Test task for listen
ansible.builtin.debug:
msg: I never run :(
listen: "my handler"
9 changes: 9 additions & 0 deletions src/ansiblelint/rules/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ def update_task_name(task_name: str) -> str:
if orig_task_name == task["notify"][idx]:
task["notify"][idx] = updated_task_name

if isinstance(item, dict) and "handlers" in item:
for task in item["handlers"]:
listener_task_name = task.get("listen", None)
if (
listener_task_name
and listener_task_name == orig_task_name
):
task["listen"] = updated_task_name

target_task["name"] = updated_task_name
match.fixed = True

Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/schemas/__store__.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/requirements.json"
},
"role-arg-spec": {
"etag": "c1eadbf5b551aeb9b8f2781728fb6d66453609b44a8921bcc65984ab3daf4bdc",
"etag": "e0f25bc37f7b43d55b8e8f41929cab803179550e237d63c1134d51dfdd985ddf",
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/role-arg-spec.json"
},
"rulebook": {
Expand Down

0 comments on commit 335088f

Please sign in to comment.