forked from ansible/ansible-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix discover_lintables: strip ./ from WcMatch return value
calling WcMatch('.', ...) causes the resulting file names to be prefixed with `./`. If the tests are run in a git-repository, this is not an issue, as git is preferred of WcMatch in the code. Therefore remove the `./` prefix from the WcMatch return value to get the identical expected output. fixes ansible#1836
- Loading branch information
Showing
9 changed files
with
82 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,7 @@ | |
- name: foo | ||
debug: | ||
msg: A 3rd BANNED line | ||
|
||
- name: bar | ||
command: echo something | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Test Rule that needs_raw_task.""" | ||
from typing import Any, Dict, Optional, Union | ||
|
||
from ansiblelint.file_utils import Lintable | ||
from ansiblelint.rules import AnsibleLintRule | ||
|
||
|
||
class RawTaskRule(AnsibleLintRule): | ||
"""Test rule that inspects the raw task.""" | ||
|
||
id = 'TEST0003' | ||
shortdesc = 'Test rule that inspects the raw task' | ||
description = ( | ||
'This is a test rule that looks in a raw task to flag raw action params.' | ||
) | ||
tags = ['fake', 'dummy', 'test3'] | ||
needs_raw_task = True | ||
|
||
def matchtask( | ||
self, task: Dict[str, Any], file: Optional[Lintable] = None | ||
) -> Union[bool, str]: | ||
"""Match a task using __raw_task__ to inspect the module params type.""" | ||
raw_task = task["__raw_task__"] | ||
module = task["action"]["__ansible_module_original__"] | ||
found_raw_task_params = not isinstance(raw_task[module], dict) | ||
return found_raw_task_params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Test rules resources.""" | ||
|
||
__all__ = ['UnsetVariableMatcherRule', 'EMatcherRule'] | ||
__all__ = ['EMatcherRule', 'RawTaskRule', 'UnsetVariableMatcherRule'] |