Top Level Namespace
Instance Method Summary collapse
- #clean_up_kitchen ⇒ Object
- #clean_up_terraform ⇒ Object
- #format_tf ⇒ Object
- #kitchen_converge ⇒ Object
- #kitchen_destroy ⇒ Object
- #kitchen_test ⇒ Object
- #kitchen_verify ⇒ Object
-
#lint_tf ⇒ Object
To use Terraform 0.12 syntax, set ENV variable TERRAFORM_VERSION to 0.12.*.
- #style_tf ⇒ Object
Instance Method Details
#clean_up_kitchen ⇒ Object
3 4 5 6 7 8 |
# File 'lib/validate/file_utils.rb', line 3 def clean_up_kitchen if File.exists? '.kitchen' print "INFO: Cleaning up the .kitchen folder...\n" FileUtils.rm_rf('.kitchen') end end |
#clean_up_terraform ⇒ Object
10 11 12 13 14 15 |
# File 'lib/validate/file_utils.rb', line 10 def clean_up_terraform if File.exists? '.terraform' print "INFO: Cleaning up the .terraform folder...\n" FileUtils.rm_rf('.terraform') end end |
#format_tf ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/validate/static_utils.rb', line 42 def format_tf # Apply the canonical format and style on current working folder. print "INFO: Formatting Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.") = `terraform fmt -diff=true 2>&1` elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.") = `terraform fmt -diff 2>&1` end # Check the styling message. if not .empty? raise "ERROR: Formatting Terraform configurations failed!\n#{}\n".red else print "INFO: Done!\n".green end end |
#kitchen_converge ⇒ Object
4 5 6 7 8 9 |
# File 'lib/validate/test_kitchen.rb', line 4 def kitchen_converge success = system("kitchen converge") if not success raise "ERROR: Test kitchen converge failed!\n".red end end |
#kitchen_destroy ⇒ Object
25 26 27 28 29 30 |
# File 'lib/validate/test_kitchen.rb', line 25 def kitchen_destroy success = system("kitchen destroy") if not success raise "ERROR: Test kitchen destroy failed!\n".red end end |
#kitchen_test ⇒ Object
18 19 20 21 22 23 |
# File 'lib/validate/test_kitchen.rb', line 18 def kitchen_test success = system("kitchen test") if not success raise "ERROR: Test kitchen test failed!\n".red end end |
#kitchen_verify ⇒ Object
11 12 13 14 15 16 |
# File 'lib/validate/test_kitchen.rb', line 11 def kitchen_verify success = system("kitchen verify") if not success raise "ERROR: Test kitchen verify failed!\n".red end end |
#lint_tf ⇒ Object
To use Terraform 0.12 syntax, set ENV variable TERRAFORM_VERSION to 0.12.*
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/validate/static_utils.rb', line 6 def lint_tf # Do the linting on current working folder. print "INFO: Linting Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.") = `terraform validate -check-variables=false 2>&1` elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.") = `terraform validate >/dev/null` end # Check the linting message. if not .empty? raise "ERROR: Linting Terraform configurations failed!\n#{}\n".red else print "INFO: Done!\n".green end end |
#style_tf ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/validate/static_utils.rb', line 25 def style_tf # Do the style checking on current working folder. print "INFO: Styling Terraform configurations...\n".yellow if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.") = `terraform fmt -check=true 2>&1` elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.") = `terraform fmt -check 2>&1` end # Check the styling message. if not .empty? raise "ERROR: Styling Terraform configurations failed!\n#{}\n".red else print "INFO: Done!\n".green end end |