Skip to content

Conversation

@cavcrosby
Copy link
Contributor

Fixes #4095.

When working on this issue, I ran into another bug when writing a test case to test my solution to the issue. The bug I ran into was when running a test case that would lint a playbook from ./examples/playbooks that contained a include_role/import_role task with a FQCN role as its argument. I noticed that the test case would pick up violations from other lintables that I didn't specify as an argument to my runner instance. I suspect this is because _rolepath currently doesn't handle FQCNs, which results in the basedir being returned and can cause _look_for_role_files to return additional unexpected files. This can be seen when running pytest test/test_utils.py::test_find_children_in_playbook from another fork branch I made to showcase this https://github.com/cavcrosby/ansible-lint/tree/ignore-foreign-role-vars-revert-utils. The changes to fix said bug are consolidated into utils.py.

To add, said bug probably won't affect an end user unless they purposefully contain violations in their Ansible yaml like in the case of ansible-lint. That said, I would think we would want to address this for development purposes.

@cavcrosby cavcrosby requested a review from a team as a code owner June 22, 2024 17:12
@cavcrosby cavcrosby requested review from audgirka and ssbarnea and removed request for a team June 22, 2024 17:12
The changes to the utils.py's _rolepath were to enable the function to
handle fully qualified collection names (FQCNs). Otherwise, the function
would be unable to parse the role name from the FQCN returning basedir
as the role_path. This can result in additional files with violations
being returned by the _look_for_role_files function.
@audgirka audgirka merged commit 251aed4 into ansible:main Jul 22, 2024
@cavcrosby cavcrosby deleted the ignore-foreign-role-vars branch July 24, 2024 12:34
@cavcrosby cavcrosby restored the ignore-foreign-role-vars branch July 24, 2024 12:34
@cavcrosby cavcrosby deleted the ignore-foreign-role-vars branch July 24, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

var-naming[pattern] is also applied to vars that are not owned by the linted code

3 participants