-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathterraform-format-pre-commit.sh
More file actions
executable file
·29 lines (25 loc) · 1.12 KB
/
terraform-format-pre-commit.sh
File metadata and controls
executable file
·29 lines (25 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
[ $(make project-check-if-tech-is-included-in-stack NAME=terraform) == false ] && exit 0
if [ "$PROJECT_NAME" == "$DEVOPS_PROJECT_NAME" ]; then
if [ $(make git-check-if-commit-changed-directory DIR=build/automation/lib/terraform/template PRECOMMIT=true) == true ]; then
if ! make -s terraform-fmt DIR=build/automation/lib/terraform/template OPTS="-check -list=false" 2> /dev/null; then
tput setaf 202
printf "\n\n $(echo $0 | sed "s;$PWD/;;"): Please, format the Terraform files in 'build/automation/lib/terraform/template'\n"
tput sgr0
exit 1
fi
fi
fi
if [ $(make git-check-if-commit-changed-directory DIR=infrastructure PRECOMMIT=true) == true ]; then
if ! make -s terraform-fmt DIR=infrastructure OPTS="-check -list=false" 2> /dev/null; then
tput setaf 202
printf "\n\n $(echo $0 | sed "s;$PWD/;;"): Please, format the Terraform files in 'infrastructure'\n"
tput sgr0
exit 1
fi
fi
# TODO: Add `make docker-run-terraform-tfsec`
# TODO: Add `make docker-run-checkov`
# TODO: Add `make docker-run-terraform-compliance`
# TODO: Add `make docker-run-config-lint`
exit 0