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
Support parsing multiple files #331
Support parsing multiple files #331
Conversation
0ff6e0b
to
e26201d
Compare
A few things may need to get done before merging this one.
|
I noticed you've removed the WIP tag from this PR -- is it ready for review and merge? |
yea I think this is about ready. In the past there has a been a few argparse things that trip me up. I'm hoping I can get a few people to put their eyes on it to make sure I didn't miss anything. |
@alexjurkiewicz and @adamchainz -- would either of you be willing to do a quick review/test of this PR to see if it helps with your multi-file use cases? |
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.
I can only get this to work if I run it as:
cfn-lint new-temp.yaml with-private-subnets.json
I can't get it to parse multiple files using -template/-t. I tried:
cfn-lint -template new-temp.yaml -template with-private-subnets.json
cfn-lint -t new-temp.yaml -t with-private-subnets.json
cfn-lint -t new-temp.yaml,with-private-subnets.json
In all cases it only parses one file or fails outright. Does this only work with bare filenames?
It should work for both... I'll check in on this. |
6f50ce4
to
5203584
Compare
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.
Ok, almost there. Now these all work:
cfn-lint -template new-temp.yaml with-private-subnets.json
cfn-lint -t new-temp.yaml,with-private-subnets.json
cfn-lint -t new-temp.yaml -t with-private-subnets.json
cfn-lint new-temp.yaml with-private-subnets.json
...but these fail:
cfn-lint -template new-temp.yaml -template with-private-subnets.json
cfn-lint new-temp.yaml,with-private-subnets.json
ps -- I have not tested with any other arguments (rules, whitelisting, etc.)
@cmmeyer comma separated lists shouldn't really pass since commas are allowed in filenames, and there's already a way of passing multiple with space separation |
Takes my lint of 73 templates from 53 seconds to 4 seconds! But one thing that might be worth documenting is using the |
It would be nice to print each filename in debug mode -- I got an exception when I pointed the linter at a random directory and it was hard to figure out which file caused the exception. (For what it's worth, the exception was when we hit a binary file(.zip). I'll create a separate issue for that)
|
25618b8
to
57a1c1e
Compare
Thanks for the feedback. Added logging for the filename information and did some extra items around the comma/space parsing. Also added some more documentation. |
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.
Great work mate! This is very exciting :)
I have tested locally and no extra bugs from what's above. A few review comments you can accept or ignore
README.md
Outdated
`cfn-lint --template template.yaml` | ||
- `cfn-lint template.yaml` | ||
- `cfn-lint --template template.yaml` | ||
- `cfn-lint -t template.yaml` |
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.
Is it worth documenting all these different ways to do the same thing so high up in the README? It will take a lot of space. If you want to show both positional and argument -t
and --template
are wholly redundant
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.
To expand on this, for quick start people probably just need to see cfn-lint template.yaml
. Other forms can be left for the --help
output.
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.
Removed --template
and moved up the usage section in the README so it isn't so far down. I will look into the adding information into the help. I think there was a request to make sure we showed the --
in the README so we didn't cause confusion when using the default parameters with other parameters. The -t
examples can be moved though.
src/cfnlint/decode/__init__.py
Outdated
def create_match_file_error(filename, msg): | ||
"""Create a Match for a parser error""" | ||
return cfnlint.Match( | ||
1, 1, 1, 2, filename, cfnlint.ParseError(), message=msg) |
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.
this function call is a bit cryptic. Should it used named parameters?
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.
Updated. Thanks!
57a1c1e
to
f9643e5
Compare
src/cfnlint/core.py
Outdated
@@ -104,10 +104,11 @@ def create_parser(): | |||
|
|||
# Alllow the template to be passes as an optional or a positional argument | |||
standard.add_argument( | |||
'template', nargs='?', help='The CloudFormation template to be linted') | |||
'template', nargs='*', help='The CloudFormation template to be linted') |
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.
This is a real nitpick, but should probably call this variable 'templates' (with a metavar of TEMPLATE).
f9643e5
to
31e9825
Compare
31e9825
to
9794c62
Compare
Top stuff guys!!
…On Thu., 27 Sep. 2018, 03:53 Chuck Meyer, ***@***.***> wrote:
Merged #331 <#331> into
master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#331 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAXKdfpdXIHU9y_LkKhGrNdCWR-7Vgwhks5ue78pgaJpZM4WfJk3>
.
|
🐇 |
I'm installing from Github because the version that is on pypi does not seem to support multiple files. I feel that it is not up-to-date. EDIT: There was a funny character on the last line of my config file which became visible once I viewed the file in |
@Saichovsky that doesn't seem related to this at all, none of the stack trace frames are in cfn-python-lint. From the stacktrace I guess you have non-unicode characters in your configuration file. |
@adamchainz Indeed. Reported on the wrong repo. Apologies. |
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.