Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore var-naming[pattern] to foreign role vars #4230

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

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.
@cavcrosby cavcrosby requested a review from a team as a code owner June 22, 2024 17:12
@cavcrosby cavcrosby requested review from ssbarnea and audgirka and removed request for a team June 22, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
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
2 participants