-
Notifications
You must be signed in to change notification settings - Fork 83
/
lint.sh
executable file
·31 lines (21 loc) · 1005 Bytes
/
lint.sh
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
#!/bin/bash
export TF_PLUGIN_CACHE_DIR=~/tf_plugin_cache_dir/.terraform.d/plugin-cache
mkdir -p ${TF_PLUGIN_CACHE_DIR}
function execute(){
sh -c "$1" 1>/dev/null
if [ $? != 0 ]; then
echo "[$1]failed!"
exit 1
else
echo "[$1] success!"
fi
}
echo "--------------------start to format terraform files--------------------"
execute "terraform fmt -recursive"
echo "--------------------finished format terraform files--------------------"
echo "--------------------start to validate terraform files--------------------"
execute "find . -name '*.tf' -print | xargs dirname | uniq | time xargs -n 1 -I{} sh -c 'terraform -chdir={} init && terraform -chdir={} validate'"
echo "--------------------finished validate terraform files--------------------"
echo "--------------------start to format markdown files--------------------"
execute "markdownlint ./ -c .markdownlint.yaml"
echo "--------------------finished format markdown files--------------------"