From 39edc45638e1aa63be5e46b5d55cbdb6e186c039 Mon Sep 17 00:00:00 2001 From: Matt White Date: Fri, 30 Aug 2019 09:30:38 +0100 Subject: [PATCH] Default to terraform 0.11 if TERRAFORM_VERSION is not set to 0.12.* --- lib/validate/static_utils.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/validate/static_utils.rb b/lib/validate/static_utils.rb index 58f3468..e533a38 100644 --- a/lib/validate/static_utils.rb +++ b/lib/validate/static_utils.rb @@ -1,13 +1,15 @@ require 'colorize' require 'fileutils' +# To use Terraform 0.12 syntax, set ENV variable TERRAFORM_VERSION to 0.12.* + def lint_tf # Do the linting on current working folder. print "INFO: Linting Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].start_with?("0.12") message = `terraform validate >/dev/null` - elsif ENV['TERRAFORM_VERSION'].start_with?("0.11") + else message = `terraform validate -check-variables=false 2>&1` end @@ -24,7 +26,7 @@ def style_tf print "INFO: Styling Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].start_with?("0.12") message = `terraform fmt -check 2>&1` - elsif ENV['TERRAFORM_VERSION'].start_with?("0.11") + else message = `terraform fmt -check=true 2>&1` end @@ -41,7 +43,7 @@ def format_tf print "INFO: Formatting Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].start_with?("0.12") message = `terraform fmt -diff 2>&1` - elsif ENV['TERRAFORM_VERSION'].start_with?("0.11") + else message = `terraform fmt -diff=true 2>&1` end