From 29a913b9ac0c834fabba51a2b01d75e8d1cb36ef Mon Sep 17 00:00:00 2001 From: Tyler Jang Date: Thu, 6 Jul 2023 10:48:26 -0700 Subject: [PATCH] Support tflint >=0.47.0 (#351) Adaptation of #350, using `target: ${parent}` to better achieve the `--chdir` behavior recommended by https://github.com/terraform-linters/tflint/pull/1687 --------- Co-authored-by: Piotr Roszatycki --- linters/tflint/plugin.yaml | 10 +++++++++ .../tflint_v0.35.0_CUSTOM.check.shot | 22 +++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/linters/tflint/plugin.yaml b/linters/tflint/plugin.yaml index c25c5193e..5eab4915a 100644 --- a/linters/tflint/plugin.yaml +++ b/linters/tflint/plugin.yaml @@ -20,6 +20,16 @@ lint: - name: tflint files: [terraform] commands: + - name: lint + output: sarif + prepare_run: tflint --init + run: tflint --format=sarif --chdir=${target} --force + success_codes: [0, 1, 2] + read_output_from: stdout + target: ${parent} + run_linter_from: root_directory + run_from_root_target: .tflint.hcl + version: ">=0.47.0" - name: lint output: sarif prepare_run: tflint --init diff --git a/linters/tflint/test_data/tflint_v0.35.0_CUSTOM.check.shot b/linters/tflint/test_data/tflint_v0.35.0_CUSTOM.check.shot index c02e03cf4..02bcf723d 100644 --- a/linters/tflint/test_data/tflint_v0.35.0_CUSTOM.check.shot +++ b/linters/tflint/test_data/tflint_v0.35.0_CUSTOM.check.shot @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Testing linter tflint test CUSTOM 1`] = ` -Object { - "issues": Array [ - Object { +{ + "issues": [ + { "code": "aws_instance_invalid_type", "column": "19", "file": "aws.tf", @@ -11,10 +11,10 @@ Object { "level": "LEVEL_HIGH", "line": "2", "linter": "tflint", - "message": "\\"t1.2xlarge\\" is an invalid value as instance_type", + "message": ""t1.2xlarge" is an invalid value as instance_type", "targetType": "terraform", }, - Object { + { "code": "aws_instance_previous_type", "column": "19", "file": "aws.tf", @@ -22,22 +22,22 @@ Object { "level": "LEVEL_MEDIUM", "line": "2", "linter": "tflint", - "message": "\\"t1.2xlarge\\" is previous generation instance type.", + "message": ""t1.2xlarge" is previous generation instance type.", "targetType": "terraform", }, ], - "lintActions": Array [ - Object { + "lintActions": [ + { "command": "lint", "fileGroupName": "terraform", "linter": "tflint", - "paths": Array [ + "paths": [ "aws.tf", ], "verb": "TRUNK_VERB_CHECK", }, ], - "taskFailures": Array [], - "unformattedFiles": Array [], + "taskFailures": [], + "unformattedFiles": [], } `;