Skip to content

Commit

Permalink
Added support for TFLint with --deep parameter (#53)
Browse files Browse the repository at this point in the history
Added support for TFLint (https://github.com/wata727/tflint).

Signed-off-by: Costin Galan <[email protected]>
  • Loading branch information
costingalan authored and antonbabenko committed Aug 20, 2019
1 parent dc8cf48 commit e0d3d61
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions terraform_tflint.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e0d3d61

Please sign in to comment.