Skip to content

Commit

Permalink
Change from sed to perl
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Nemetz committed Aug 30, 2018
1 parent 0d96ea6 commit 5154879
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions tflint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
#!/usr/bin/env bash

# TODO: build config to ignore modules until supports registry paths
if [ $(uname -s) == "Darwin" ]; then
cmd_sed='sed -E'
else
cmd_sed='sed -r'
fi
#echo "Configuring tflint..."
tf_ver=$(terraform version | awk 'FNR <= 1' | cut -dv -f2)
echo -e "\tConfig tflint for terraform version: ${tf_ver}"
if [ -f '.tflint.hcl' ]; then
sed -i "/terraform_version =/s/\".*\"/\"${tf_ver}\"/" .tflint.hcl
perl -pi -e "s/\".*\"/\"${tf_ver}\"/ if /terraform_version =/" .tflint.hcl
else
{
echo -e "config {\nterraform_version = \"${tf_ver}\"\ndeep_check = true\nignore_module = {"
for module in $(grep -h '[^a-zA-Z]source[ =]' *.tf | ${sed_cmd} 's/.*=\s+//' | sort -u); do
for module in $(grep -h '[^a-zA-Z]source[ =]' *.tf | perl -pe 's/^.*=\s+//' | sort -u); do
# if not ^"../
echo "${module} = true"
done
Expand Down

0 comments on commit 5154879

Please sign in to comment.