mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 06:01:05 -05:00
Add terraform fmt support
This commit is contained in:
parent
6b6451f129
commit
9f4a208eb5
6 changed files with 61 additions and 3 deletions
19
.automation/test/terraform_fmt/README.md
Normal file
19
.automation/test/terraform_fmt/README.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# AWS States language Test Cases
|
||||||
|
|
||||||
|
This folder holds the test cases for **Terraform Formatting**.
|
||||||
|
|
||||||
|
## Additional Docs
|
||||||
|
|
||||||
|
No Additional information is needed for this test case.
|
||||||
|
|
||||||
|
## Good Test Cases
|
||||||
|
|
||||||
|
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||||
|
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
||||||
|
|
||||||
|
## Bad Test Cases
|
||||||
|
|
||||||
|
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||||
|
|
||||||
|
- **Note:** They are linted utilizing the default linter rules.
|
18
.automation/test/terraform_fmt/bad/terraform_fmt_bad_1.tf
Normal file
18
.automation/test/terraform_fmt/bad/terraform_fmt_bad_1.tf
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
resource "aws_instance" "instanceWithVpc" {
|
||||||
|
ami = "some-id"
|
||||||
|
instance_type = "t2.micro"
|
||||||
|
|
||||||
|
monitoring = true
|
||||||
|
ebs_optimized = true
|
||||||
|
|
||||||
|
vpc_security_group_ids = ["sg-12345678901234567"]
|
||||||
|
subnet_id = "subnet-12345678901234567"
|
||||||
|
|
||||||
|
metadata_options {
|
||||||
|
http_endpoint = "disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
Name = "HelloWorld"
|
||||||
|
}
|
||||||
|
}
|
18
.automation/test/terraform_fmt/good/terraform_fmt_good_1.tf
Normal file
18
.automation/test/terraform_fmt/good/terraform_fmt_good_1.tf
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
resource "aws_instance" "instanceWithVpc" {
|
||||||
|
ami = "some-id"
|
||||||
|
instance_type = "t2.micro"
|
||||||
|
|
||||||
|
monitoring = true
|
||||||
|
ebs_optimized = true
|
||||||
|
|
||||||
|
vpc_security_group_ids = ["sg-12345678901234567"]
|
||||||
|
subnet_id = "subnet-12345678901234567"
|
||||||
|
|
||||||
|
metadata_options {
|
||||||
|
http_endpoint = "disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
Name = "HelloWorld"
|
||||||
|
}
|
||||||
|
}
|
|
@ -97,7 +97,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their codebase w
|
||||||
| **Snakemake** | [snakefmt](https://github.com/snakemake/snakefmt/) / [snakemake --lint](https://snakemake.readthedocs.io/en/stable/snakefiles/writing_snakefiles.html#best-practices) |
|
| **Snakemake** | [snakefmt](https://github.com/snakemake/snakefmt/) / [snakemake --lint](https://snakemake.readthedocs.io/en/stable/snakefiles/writing_snakefiles.html#best-practices) |
|
||||||
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) / [sqlfluff](https://github.com/sqlfluff/sqlfluff) |
|
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) / [sqlfluff](https://github.com/sqlfluff/sqlfluff) |
|
||||||
| **Tekton** | [tekton-lint](https://github.com/IBM/tekton-lint) |
|
| **Tekton** | [tekton-lint](https://github.com/IBM/tekton-lint) |
|
||||||
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) / [terrascan](https://github.com/accurics/terrascan) |
|
| **Terraform** | [fmt](https://github.com/hashicorp/terraform) / [tflint](https://github.com/terraform-linters/tflint) / [terrascan](https://github.com/accurics/terrascan) |
|
||||||
| **Terragrunt** | [terragrunt](https://github.com/gruntwork-io/terragrunt) |
|
| **Terragrunt** | [terragrunt](https://github.com/gruntwork-io/terragrunt) |
|
||||||
| **TypeScript** | [ESLint](https://eslint.org/) / [standard js](https://standardjs.com/) |
|
| **TypeScript** | [ESLint](https://eslint.org/) / [standard js](https://standardjs.com/) |
|
||||||
| **XML** | [LibXML](http://xmlsoft.org/) |
|
| **XML** | [LibXML](http://xmlsoft.org/) |
|
||||||
|
|
|
@ -723,6 +723,7 @@ function BuildFileList() {
|
||||||
################################
|
################################
|
||||||
FILE_ARRAY_TERRAFORM_TFLINT+=("${FILE}")
|
FILE_ARRAY_TERRAFORM_TFLINT+=("${FILE}")
|
||||||
FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}")
|
FILE_ARRAY_TERRAFORM_TERRASCAN+=("${FILE}")
|
||||||
|
FILE_ARRAY_TERRAFORM_FMT+=("${FILE}")
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# Get the Terragrunt files #
|
# Get the Terragrunt files #
|
||||||
|
|
|
@ -259,8 +259,8 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLANG_FORMAT'
|
||||||
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'R' 'RAKU' 'RUBY' 'RUST_2015'
|
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'R' 'RAKU' 'RUBY' 'RUST_2015'
|
||||||
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
|
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
|
||||||
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
|
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
|
||||||
'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX' 'TYPESCRIPT_ES'
|
'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX'
|
||||||
"${TYPESCRIPT_STYLE_NAME}" 'XML' 'YAML')
|
'TYPESCRIPT_ES' "${TYPESCRIPT_STYLE_NAME}" 'XML' 'YAML')
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# Linter command names array #
|
# Linter command names array #
|
||||||
|
@ -330,6 +330,7 @@ LINTER_NAMES_ARRAY['STATES']="asl-validator"
|
||||||
LINTER_NAMES_ARRAY['SQL']="sql-lint"
|
LINTER_NAMES_ARRAY['SQL']="sql-lint"
|
||||||
LINTER_NAMES_ARRAY['SQLFLUFF']="sqlfluff"
|
LINTER_NAMES_ARRAY['SQLFLUFF']="sqlfluff"
|
||||||
LINTER_NAMES_ARRAY['TEKTON']="tekton-lint"
|
LINTER_NAMES_ARRAY['TEKTON']="tekton-lint"
|
||||||
|
LINTER_NAMES_ARRAY['TERRAFORM_FMT']="terraform"
|
||||||
LINTER_NAMES_ARRAY['TERRAFORM_TFLINT']="tflint"
|
LINTER_NAMES_ARRAY['TERRAFORM_TFLINT']="tflint"
|
||||||
LINTER_NAMES_ARRAY['TERRAFORM_TERRASCAN']="terrascan"
|
LINTER_NAMES_ARRAY['TERRAFORM_TERRASCAN']="terrascan"
|
||||||
LINTER_NAMES_ARRAY['TERRAGRUNT']="terragrunt"
|
LINTER_NAMES_ARRAY['TERRAGRUNT']="terragrunt"
|
||||||
|
@ -966,6 +967,7 @@ LINTER_COMMANDS_ARRAY['STATES']="asl-validator --json-path"
|
||||||
LINTER_COMMANDS_ARRAY['SQL']="sql-lint --config ${SQL_LINTER_RULES}"
|
LINTER_COMMANDS_ARRAY['SQL']="sql-lint --config ${SQL_LINTER_RULES}"
|
||||||
LINTER_COMMANDS_ARRAY['SQLFLUFF']="sqlfluff lint --config ${SQLFLUFF_LINTER_RULES}"
|
LINTER_COMMANDS_ARRAY['SQLFLUFF']="sqlfluff lint --config ${SQLFLUFF_LINTER_RULES}"
|
||||||
LINTER_COMMANDS_ARRAY['TEKTON']="tekton-lint"
|
LINTER_COMMANDS_ARRAY['TEKTON']="tekton-lint"
|
||||||
|
LINTER_COMMANDS_ARRAY['TERRAFORM_FMT']="terraform fmt -check"
|
||||||
LINTER_COMMANDS_ARRAY['TERRAFORM_TFLINT']="tflint -c ${TERRAFORM_TFLINT_LINTER_RULES}"
|
LINTER_COMMANDS_ARRAY['TERRAFORM_TFLINT']="tflint -c ${TERRAFORM_TFLINT_LINTER_RULES}"
|
||||||
LINTER_COMMANDS_ARRAY['TERRAFORM_TERRASCAN']="terrascan scan -i terraform -t all -c ${TERRAFORM_TERRASCAN_LINTER_RULES} -f"
|
LINTER_COMMANDS_ARRAY['TERRAFORM_TERRASCAN']="terrascan scan -i terraform -t all -c ${TERRAFORM_TERRASCAN_LINTER_RULES} -f"
|
||||||
LINTER_COMMANDS_ARRAY['TERRAGRUNT']="terragrunt hclfmt --terragrunt-check --terragrunt-log-level error --terragrunt-hclfmt-file"
|
LINTER_COMMANDS_ARRAY['TERRAGRUNT']="terragrunt hclfmt --terragrunt-check --terragrunt-log-level error --terragrunt-hclfmt-file"
|
||||||
|
|
Loading…
Reference in a new issue