-
Notifications
You must be signed in to change notification settings - Fork 654
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
Adds experimental stdin support #1355
Conversation
Allow ansible-lint to perform linting from stdin when filename argument '/dev/stdin' or '-' are given. Keep in mind: - no argument still means auto-detect as I found no reliable way to identify that the tool was used with shell pipes - filename reported is 'stdin', same as flake8 does - received content is assumed to be a playbook, you cannot lint a task file this way. Others are welcomed to propose improvements for detecting the file type based on its content, because we do not have any `filename` available.
for match in matches: | ||
for lintable in lintables: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using an itertools.product()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really as I do also have the break.
if self.kind == "role": | ||
self.dir = str(self.path.resolve()) | ||
if str(self.path) in ['/dev/stdin', '-']: | ||
self.file = NamedTemporaryFile(mode="w+", suffix="playbook.yml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be kept in-memory instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope because I do need to feed ansible-playbook --syntax-check
a file. The rest of the linter code could work fine with in-memory files, but not ansible itself.
Allow ansible-lint to perform linting from stdin when filename arguments as
/dev/stdin
or-
are given.Keep in mind:
filename
available.Fixes: #790