Added support for TFLint with --deep parameter (#53)

Added support for TFLint (https://github.com/wata727/tflint).

Signed-off-by: Costin Galan <costin.galan@mambu.com>
This commit is contained in:
Costin GALAN 2019-08-20 22:31:28 +03:00 committed by Anton Babenko
commit e0d3d61422
2 changed files with 31 additions and 0 deletions

View file

@ -42,6 +42,14 @@
files: (\.tf|\.tfvars)$
exclude: \.terraform\/.*$
- id: terraform_tflint
name: Terraform validate with tflint
description: Validates all Terraform configuration files with TFLint.
entry: terraform_tflint.sh
language: script
files: (\.tf|\.tfvars)$
exclude: \.terraform\/.*$
- id: terragrunt_fmt
name: Terragrunt fmt
description: Rewrites all Terragrunt configuration files to a canonical format.

23
terraform_tflint.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
declare -a paths
declare -a tfvars_files
index=0
for file_with_path in "$@"; do
file_with_path="${file_with_path// /__REPLACED__SPACE__}"
paths[index]=$(dirname "$file_with_path")
let "index+=1"
done
for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
path_uniq="${path_uniq//__REPLACED__SPACE__/ }"
pushd "$path_uniq" > /dev/null
tflint --deep
popd > /dev/null
done