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

Validate deployment files #3884

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ Optional parameters:
| -h, --help | | | Get description of cfn-lint |
| -z, --custom-rules | | filename | Text file containing user-defined custom rules. See [here](#Custom-Rules) for more information |
| -t, --template | | filename | Alternative way to specify Template file path to the file that needs to be tested by cfn-lint |
| --deployment-files | deployment_files | | Specify deployment files that are used to configure the template runner. This will specify templates and parameters and you don't specify parameters or parameter files with this parameter. Examples of a deployment include: [GitSync](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/git-sync.html)
| --parameters | parameters | | Specify a list of parameters using the format `Key=Value`
| --parameter-files | parameter_files | | A list of parameter files that would be used when using the aws cli
| -f, --format | format | quiet, parseable, json, junit, pretty, sarif | Output format |
| -l, --list-rules | | | List all the rules |
| -r, --regions | regions | [REGIONS [REGIONS ...]], ALL_REGIONS | Test the template against many regions. [Supported regions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-type-schemas.html) |
Expand Down
13 changes: 9 additions & 4 deletions src/cfnlint/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from cfnlint.decode.decode import decode_str
from cfnlint.helpers import REGION_PRIMARY, REGIONS
from cfnlint.rules import Match, RulesCollection
from cfnlint.runner import Runner, TemplateRunner
from cfnlint.runner import Runner, run_template_by_data

Matches = List[Match]

Expand Down Expand Up @@ -56,11 +56,16 @@ def lint(
config_mixin = ConfigMixIn(**config)

if isinstance(rules, RulesCollection):
template_runner = TemplateRunner(None, template, config_mixin, rules) # type: ignore # noqa: E501
return list(template_runner.run())
return list(
run_template_by_data(
template,
config_mixin,
rules, # type: ignore
)
)

runner = Runner(config_mixin)
return list(runner.validate_template(None, template))
return list(runner.validate_template(template))


def lint_all(s: str) -> list[Match]:
Expand Down
Loading
Loading