Skip to content

Commit a11d860

Browse files
committed
Update CircleCI config
1 parent c9f5027 commit a11d860

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

.circleci/config.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
jobs:
44
build:
55
docker:
6-
- image: hashicorp/terraform:0.11.2
6+
- image: hashicorp/terraform:0.11.3
77
entrypoint: /bin/sh
88
steps:
99
- checkout
@@ -23,21 +23,43 @@ jobs:
2323
- run:
2424
name: "Install: tflint"
2525
command: |
26-
apk add wget
27-
wget https://github.com/wata727/tflint/releases/download/v0.5.4/tflint_linux_amd64.zip
26+
apk add jq wget
27+
# Get latest version of tflint
28+
pkg_arch=linux_amd64
29+
dl_url=$(curl -s https://api.github.com/repos/wata727/tflint/releases/latest | jq -r ".assets[] | select(.name | test(\"${pkg_arch}\")) | .browser_download_url")
30+
wget ${dl_url}
2831
unzip tflint_linux_amd64.zip
2932
mkdir -p /usr/local/tflint/bin
30-
export PATH=/usr/local/tflint/bin:$PATH
33+
# Setup PATH for later run steps - ONLY for Bash and not in Bash
34+
#echo 'export PATH=/usr/local/tflint/bin:$PATH' >> $BASH_ENV
35+
echo "Installing tflint..."
3136
install tflint /usr/local/tflint/bin
32-
#- run:
33-
# # Not supporting modules from registry ?? v0.5.4
34-
# name: "Check: tflint"
35-
# command: |
36-
# echo "Initializing terraform..."
37-
# terraform init -input=false
38-
# echo "Running tflint..."
39-
# /usr/local/tflint/bin/tflint --version
40-
# /usr/local/tflint/bin/tflint
37+
echo "Configuring tflint..."
38+
tf_ver=$(terraform version | awk 'FNR <= 1' | cut -dv -f2)
39+
echo -e "\tConfig for terraform version: ${tf_ver}"
40+
if [ -f '.tflint.hcl' ]; then
41+
sed -i "/terraform_version =/s/\".*\"/\"${tf_ver}\"/" .tflint.hcl
42+
else
43+
{
44+
echo -e "config {\nterraform_version = \"${tf_ver}\"\ndeep_check = true\nignore_module = {"
45+
for module in $(grep -h '[^a-zA-Z]source[ =]' *.tf | sed -r 's/.*=\s+//' | sort -u); do
46+
echo "${module} = true"
47+
done
48+
echo "}}"
49+
} > .tflint.hcl
50+
fi
51+
echo "tflint configuration:"
52+
cat .tflint.hcl
53+
- run:
54+
# Not supporting modules from registry ?? v0.5.4
55+
# For now, must ignore in config file
56+
name: "Check: tflint"
57+
command: |
58+
#echo "Initializing terraform..."
59+
#terraform init -input=false
60+
echo "Running tflint..."
61+
/usr/local/tflint/bin/tflint --version
62+
/usr/local/tflint/bin/tflint
4163
4264
workflows:
4365
version: 2

0 commit comments

Comments
 (0)