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

Support tflint >= v0.47.0 #540

Closed
ponkio-o opened this issue Jun 18, 2023 · 5 comments · Fixed by #542
Closed

Support tflint >= v0.47.0 #540

ponkio-o opened this issue Jun 18, 2023 · 5 comments · Fixed by #542

Comments

@ponkio-o
Copy link

Hi @suzuki-shunsuke,

Thank you for developing this actions. I'm reporting that updating tflint didn't work.

What happened?

An error occured when I used tflint v0.47.0 on tfaction v0.6.1.
image

Run suzuki-shunsuke/github-action-tfsec@07dc756febfc0f4440e37e5d20252676510a3a65
Running tfsec
/home/runner/.local/share/aquaproj-aqua/bin/tfsec --format json .
time="2023-06-18T09:30:14Z" level=info msg="download and unarchive the package" aqua_version=2.9.0 env=linux/amd64 exe_name=tfsec package=aquasecurity/tfsec package_name=aquasecurity/tfsec package_version=v1.28.1 program=aqua registry=standard
{
	"results": []
}
Parsing tfsec result
Running reviewdog
/home/runner/.local/share/aquaproj-aqua/bin/reviewdog -f rdjson -name tfsec -filter-mode nofilter -reporter github-pr-review -level warning -fail-on-error 1
time="2023-06-18T09:30:15Z" level=info msg="download and unarchive the package" aqua_version=2.9.0 env=linux/amd64 exe_name=reviewdog package=reviewdog/reviewdog package_name=reviewdog/reviewdog package_version=v0.14.1 program=aqua registry=standard
Run suzuki-shunsuke/github-action-tflint@8537c87946e37702b4c6137bf65afdc8b049b34b
Running tflint --init
/home/runner/.local/share/aquaproj-aqua/bin/tflint --init
time="2023-06-18T09:30:17Z" level=info msg="download and unarchive the package" aqua_version=2.9.0 env=linux/amd64 exe_name=tflint package=terraform-linters/tflint package_name=terraform-linters/tflint package_version=v0.47.0 program=aqua registry=standard
Running tflint
/home/runner/.local/share/aquaproj-aqua/bin/tflint --format json --module .
{"issues":[],"errors":[{"message":"Command line arguments support was dropped in v0.47. Use --chdir or --filter instead.","severity":"error"}]}Parsing tflint result
Error: Cannot read properties of undefined (reading 'filename')

It appears thath some CLI arguments have been removed on v0.47.0.
terraform-linters/tflint#1779

Fixing it here seems to work well, but backward compatibility will need to be maintained.

const out = await exec.getExecOutput('tflint', ['--format', 'json', '--module', '.'], {

Environment

tfaction: v0.6.1
tflint: v0.47.0

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Jun 18, 2023

Thank you for your report!

Command line arguments support was dropped in v0.47. Use --chdir or --filter instead.
tflint --format json --module .
      --chdir=DIR                                               Switch to a different working directory before executing the

https://github.com/terraform-linters/tflint/releases/tag/v0.46.0

Warn when using command line arguments like tflint dir and tflint main.tf. The former can be replaced with tflint --chdir=dir and the latter with tflint --filter=main.tf. See terraform-linters/tflint#1687 for details.

$ tflint --chdir=modules/production
// replacement of "tflint modules/production"

So, I guess tflint --format json --module, removing the argument ".", works well.

https://github.com/terraform-linters/tflint/blob/3e1937a0b2f2c309f7cc43a6ce560d02861218ed/README.md?plain=1#L115

TFLint inspects files under the current directory by default.

I think the command line argument "." isn't needed. I'm not sure why we specify this argument, but I think we can simply remove this.

@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke added a commit that referenced this issue Jun 18, 2023
* chore: install ncc

* feat: remove the command line argument "." to support tflint v0.47.0

- #540 (comment)

* chore: update tflint to v0.47.0
@suzuki-shunsuke
Copy link
Owner

@suzuki-shunsuke
Copy link
Owner

I've confirmed this works with tflint v0.29.0 and v0.47.0.

@suzuki-shunsuke
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants