terramodtest 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9fce750c87445c4d216b49552724ebc92e0e3d52d9e6f38a5849561aef268e7e
4
+ data.tar.gz: 8ea6268528630651d4284cce7374cd496a817786f06c6c110ae72f7794ddb080
5
+ SHA512:
6
+ metadata.gz: cc77a2bdd5ca95689427b06098cb448ae3d2ae8eb8be10f4d97e70fca6e1b6a4cee0af580d3999776ffdfb704f0d6c4d290d58faf85e01ec475f049d33f498f6
7
+ data.tar.gz: decbf1e144d4aef5c87470cd73f8aaf2e708ccc2c6a234c72ece1f4e79babbe1f6a653f2fb220407b1b8025fe329e1b3caf316fcd5b6937758ede0cdcb92f0a5
@@ -0,0 +1,3 @@
1
+ require 'validate/file_utils.rb'
2
+ require 'validate/static_utils.rb'
3
+ require 'validate/test_kitchen.rb'
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+
3
+ def clean_up_kitchen
4
+ if File.exists? '.kitchen'
5
+ print "INFO: Cleaning up the .kitchen folder...\n"
6
+ FileUtils.rm_rf('.kitchen')
7
+ end
8
+ end
9
+
10
+ def clean_up_terraform
11
+ if File.exists? '.terraform'
12
+ print "INFO: Cleaning up the .terraform folder...\n"
13
+ FileUtils.rm_rf('.terraform')
14
+ end
15
+ end
@@ -0,0 +1,57 @@
1
+ require 'colorize'
2
+ require 'fileutils'
3
+
4
+ # To use Terraform 0.12 syntax, set ENV variable TERRAFORM_VERSION to 0.12.*
5
+
6
+ def lint_tf
7
+ # Do the linting on current working folder.
8
+ print "INFO: Linting Terraform configurations...\n".yellow
9
+
10
+
11
+ if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.")
12
+ message = `terraform validate -check-variables=false 2>&1`
13
+ elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.")
14
+ message = `terraform validate >/dev/null`
15
+ end
16
+
17
+ # Check the linting message.
18
+ if not message.empty?
19
+ raise "ERROR: Linting Terraform configurations failed!\n#{message}\n".red
20
+ else
21
+ print "INFO: Done!\n".green
22
+ end
23
+ end
24
+
25
+ def style_tf
26
+ # Do the style checking on current working folder.
27
+ print "INFO: Styling Terraform configurations...\n".yellow
28
+ if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.")
29
+ message = `terraform fmt -check=true 2>&1`
30
+ elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.")
31
+ message = `terraform fmt -check 2>&1`
32
+ end
33
+
34
+ # Check the styling message.
35
+ if not message.empty?
36
+ raise "ERROR: Styling Terraform configurations failed!\n#{message}\n".red
37
+ else
38
+ print "INFO: Done!\n".green
39
+ end
40
+ end
41
+
42
+ def format_tf
43
+ # Apply the canonical format and style on current working folder.
44
+ print "INFO: Formatting Terraform configurations...\n".yellow
45
+ if ENV['TERRAFORM_VERSION'].nil? || ENV['TERRAFORM_VERSION'].start_with?("0.11.")
46
+ message = `terraform fmt -diff=true 2>&1`
47
+ elsif ENV['TERRAFORM_VERSION'].start_with?("0.12.")
48
+ message = `terraform fmt -diff 2>&1`
49
+ end
50
+
51
+ # Check the styling message.
52
+ if not message.empty?
53
+ raise "ERROR: Formatting Terraform configurations failed!\n#{message}\n".red
54
+ else
55
+ print "INFO: Done!\n".green
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ require 'colorize'
2
+ require 'fileutils'
3
+
4
+ def kitchen_converge
5
+ success = system("kitchen converge")
6
+ if not success
7
+ raise "ERROR: Test kitchen converge failed!\n".red
8
+ end
9
+ end
10
+
11
+ def kitchen_verify
12
+ success = system("kitchen verify")
13
+ if not success
14
+ raise "ERROR: Test kitchen verify failed!\n".red
15
+ end
16
+ end
17
+
18
+ def kitchen_test
19
+ success = system("kitchen test")
20
+ if not success
21
+ raise "ERROR: Test kitchen test failed!\n".red
22
+ end
23
+ end
24
+
25
+ def kitchen_destroy
26
+ success = system("kitchen destroy")
27
+ if not success
28
+ raise "ERROR: Test kitchen destroy failed!\n".red
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terramodtest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - Su Shi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.0
27
+ description: Provide test utilities for terraform module developer.
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/terramodtest.rb
34
+ - lib/validate/file_utils.rb
35
+ - lib/validate/static_utils.rb
36
+ - lib/validate/test_kitchen.rb
37
+ homepage:
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ source_code_uri: https://github.com/Azure/terramodtest/tree/v0.4.0/validate
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.3.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements:
57
+ - none
58
+ rubygems_version: 3.1.2
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Test utilities for terraform modules.
62
+ test_files: []