kitchen-terraform 3.3.0 → 3.3.1

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/kitchen/driver/terraform.rb +127 -35
  5. data/lib/kitchen/provisioner/terraform.rb +7 -1
  6. data/lib/kitchen/{verifier.rb → terraform/breaking.rb} +3 -4
  7. data/lib/kitchen/{driver.rb → terraform/breaking/kitchen_instance.rb} +4 -3
  8. data/lib/kitchen/terraform/config_attribute.rb +68 -4
  9. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +10 -38
  10. data/lib/kitchen/terraform/config_attribute/color.rb +10 -35
  11. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +10 -29
  12. data/lib/kitchen/terraform/config_attribute/groups.rb +10 -28
  13. data/lib/kitchen/terraform/config_attribute/lock.rb +10 -33
  14. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +10 -34
  15. data/lib/kitchen/terraform/config_attribute/parallelism.rb +10 -34
  16. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +0 -5
  17. data/lib/kitchen/terraform/config_attribute/variable_files.rb +0 -9
  18. data/lib/kitchen/terraform/config_attribute/variables.rb +10 -38
  19. data/lib/kitchen/{provisioner.rb → terraform/config_attribute_type.rb} +3 -4
  20. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +51 -0
  21. data/lib/kitchen/terraform/config_attribute_type/integer.rb +47 -0
  22. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +9 -0
  23. data/lib/kitchen/terraform/configurable.rb +11 -7
  24. data/lib/kitchen/terraform/{config_schemas/integer.rb → deprecating.rb} +4 -10
  25. data/lib/kitchen/terraform/deprecating/kitchen_instance.rb +61 -0
  26. data/lib/kitchen/terraform/kitchen_instance.rb +49 -0
  27. data/lib/kitchen/terraform/version.rb +23 -1
  28. data/lib/kitchen/verifier/terraform.rb +7 -1
  29. metadata +26 -22
  30. metadata.gz.sig +0 -0
  31. data/lib/kitchen/terraform/config_schemas/hash_of_symbols_and_strings.rb +0 -32
@@ -16,8 +16,6 @@
16
16
 
17
17
  require "kitchen"
18
18
  require "kitchen/terraform/config_attribute"
19
- require "kitchen/terraform/config_attribute_cacher"
20
- require "kitchen/terraform/config_attribute_definer"
21
19
  require "kitchen/terraform/config_schemas/boolean"
22
20
 
23
21
  # This attribute toggles colored output from systems invoked by the plugin.
@@ -30,38 +28,15 @@ require "kitchen/terraform/config_schemas/boolean"
30
28
  # Caveat:: This attribute does not toggle colored output from the Test Kitchen core, though it does use the same default
31
29
  # logic. To toggle colored output from the core, the +--color+ and +--no-color+ command-line flags must be
32
30
  # used.
33
- #
34
- # @abstract It must be included by plugin class in order to be used.
35
31
  module ::Kitchen::Terraform::ConfigAttribute::Color
36
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
37
- #
38
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
39
- # @return [void]
40
- def self.included(plugin_class)
41
- ::Kitchen::Terraform::ConfigAttributeDefiner
42
- .new(
43
- attribute: self,
44
- schema: ::Kitchen::Terraform::ConfigSchemas::Boolean
45
- )
46
- .define plugin_class: plugin_class
47
- end
48
-
49
- # @return [::Symbol] the symbol corresponding to the attribute.
50
- def self.to_sym
51
- :color
52
- end
53
-
54
- extend ::Kitchen::Terraform::ConfigAttributeCacher
55
-
56
- # The default value depends on the presence of a terminal device associated with the Test Kitchen process.
57
- #
58
- # @return [Boolean] if a terminal device is associated then +true+; else +false+.
59
- def config_color_default_value
60
- ::Kitchen.tty?
61
- end
62
-
63
- # @return [::String] the toggle converted to a flag.
64
- def config_color_flag
65
- config_color and "" or "-no-color"
66
- end
32
+ ::Kitchen::Terraform::ConfigAttribute
33
+ .new(
34
+ attribute: :color,
35
+ default_value:
36
+ lambda do
37
+ ::Kitchen.tty?
38
+ end,
39
+ schema: ::Kitchen::Terraform::ConfigSchemas::Boolean
40
+ )
41
+ .apply config_attribute: self
67
42
  end
@@ -15,9 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
- require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_attribute_definer"
20
- require "kitchen/terraform/config_schemas/integer"
18
+ require "kitchen/terraform/config_attribute_type/integer"
21
19
 
22
20
  # This attribute controls the number of seconds that the plugin will wait for Terraform commands to finish running.
23
21
  #
@@ -25,31 +23,14 @@ require "kitchen/terraform/config_schemas/integer"
25
23
  # Required:: False
26
24
  # Default:: +600+
27
25
  # Example:: <code>command_timeout: 1200</code>
28
- #
29
- # @abstract It must be included by a plugin class in order to be used.
30
26
  module ::Kitchen::Terraform::ConfigAttribute::CommandTimeout
31
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
32
- #
33
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
34
- # @return [void]
35
- def self.included(plugin_class)
36
- ::Kitchen::Terraform::ConfigAttributeDefiner
37
- .new(
38
- attribute: self,
39
- schema: ::Kitchen::Terraform::ConfigSchemas::Integer
40
- )
41
- .define plugin_class: plugin_class
42
- end
43
-
44
- # @return [::Symbol] the symbol corresponding to the attribute.
45
- def self.to_sym
46
- :command_timeout
47
- end
48
-
49
- extend ::Kitchen::Terraform::ConfigAttributeCacher
50
-
51
- # @return [::Integer] 600.
52
- def config_command_timeout_default_value
53
- 600
54
- end
27
+ ::Kitchen::Terraform::ConfigAttributeType::Integer
28
+ .apply(
29
+ attribute: :command_timeout,
30
+ config_attribute: self,
31
+ default_value:
32
+ lambda do
33
+ 600
34
+ end
35
+ )
55
36
  end
@@ -15,8 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
- require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_attribute_definer"
20
18
  require "kitchen/terraform/config_schemas/groups"
21
19
 
22
20
  # This attribute configures the execution of {https://www.inspec.io/docs/reference/profiles/ InSpec profiles} against
@@ -136,31 +134,15 @@ require "kitchen/terraform/config_schemas/groups"
136
134
  # name: a_group_with_a_username
137
135
  # username: tester
138
136
  # Caveat:: If this key is omitted then the username of the Test Kitcen SSH Transport will be used.
139
- #
140
- # @abstract It must be included by a plugin class in order to be used.
141
137
  module ::Kitchen::Terraform::ConfigAttribute::Groups
142
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
143
- #
144
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
145
- # @return [void]
146
- def self.included(plugin_class)
147
- ::Kitchen::Terraform::ConfigAttributeDefiner
148
- .new(
149
- attribute: self,
150
- schema: ::Kitchen::Terraform::ConfigSchemas::Groups
151
- )
152
- .define plugin_class: plugin_class
153
- end
154
-
155
- # @return [::Symbol] the symbol corresponding to the attribute.
156
- def self.to_sym
157
- :groups
158
- end
159
-
160
- extend ::Kitchen::Terraform::ConfigAttributeCacher
161
-
162
- # @return [::Array] an empty array.
163
- def config_groups_default_value
164
- []
165
- end
138
+ ::Kitchen::Terraform::ConfigAttribute
139
+ .new(
140
+ attribute: :groups,
141
+ default_value:
142
+ lambda do
143
+ []
144
+ end,
145
+ schema: ::Kitchen::Terraform::ConfigSchemas::Groups
146
+ )
147
+ .apply config_attribute: self
166
148
  end
@@ -16,8 +16,6 @@
16
16
 
17
17
  require "kitchen"
18
18
  require "kitchen/terraform/config_attribute"
19
- require "kitchen/terraform/config_attribute_cacher"
20
- require "kitchen/terraform/config_attribute_definer"
21
19
  require "kitchen/terraform/config_schemas/boolean"
22
20
 
23
21
  # This attribute toggles {https://www.terraform.io/docs/state/locking.html locking of the Terraform state file}.
@@ -26,36 +24,15 @@ require "kitchen/terraform/config_schemas/boolean"
26
24
  # Required:: False
27
25
  # Default:: +true+
28
26
  # Example:: <code>lock: false</code>
29
- #
30
- # @abstract It must be included by plugin class in order to be used.
31
27
  module ::Kitchen::Terraform::ConfigAttribute::Lock
32
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
33
- #
34
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
35
- # @return [void]
36
- def self.included(plugin_class)
37
- ::Kitchen::Terraform::ConfigAttributeDefiner
38
- .new(
39
- attribute: self,
40
- schema: ::Kitchen::Terraform::ConfigSchemas::Boolean
41
- )
42
- .define plugin_class: plugin_class
43
- end
44
-
45
- # @return [::Symbol] the symbol corresponding to the attribute.
46
- def self.to_sym
47
- :lock
48
- end
49
-
50
- extend ::Kitchen::Terraform::ConfigAttributeCacher
51
-
52
- # @return [true]
53
- def config_lock_default_value
54
- true
55
- end
56
-
57
- # @return [::String] the toggle converted to a flag.
58
- def config_lock_flag
59
- "-lock=#{config_lock}"
60
- end
28
+ ::Kitchen::Terraform::ConfigAttribute
29
+ .new(
30
+ attribute: :lock,
31
+ default_value:
32
+ lambda do
33
+ true
34
+ end,
35
+ schema: ::Kitchen::Terraform::ConfigSchemas::Boolean
36
+ )
37
+ .apply config_attribute: self
61
38
  end
@@ -15,9 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
- require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_attribute_definer"
20
- require "kitchen/terraform/config_schemas/integer"
18
+ require "kitchen/terraform/config_attribute_type/integer"
21
19
 
22
20
  # This attribute controls the number of seconds that Terraform will wait for a lock on the state to be obtained during
23
21
  # {https://www.terraform.io/docs/state/locking.html operations related to state}.
@@ -26,36 +24,14 @@ require "kitchen/terraform/config_schemas/integer"
26
24
  # Required:: False
27
25
  # Default:: +0+
28
26
  # Example:: <code>lock_timeout: 10</code>
29
- #
30
- # @abstract It must be included by a plugin class in order to be used.
31
27
  module ::Kitchen::Terraform::ConfigAttribute::LockTimeout
32
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
33
- #
34
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
35
- # @return [void]
36
- def self.included(plugin_class)
37
- ::Kitchen::Terraform::ConfigAttributeDefiner
38
- .new(
39
- attribute: self,
40
- schema: ::Kitchen::Terraform::ConfigSchemas::Integer
41
- )
42
- .define plugin_class: plugin_class
43
- end
44
-
45
- # @return [::Symbol] the symbol corresponding to the attribute.
46
- def self.to_sym
47
- :lock_timeout
48
- end
49
-
50
- extend ::Kitchen::Terraform::ConfigAttributeCacher
51
-
52
- # @return [::Integer] 0.
53
- def config_lock_timeout_default_value
54
- 0
55
- end
56
-
57
- # @return [::String] the value converted to a flag.
58
- def config_lock_timeout_flag
59
- "-lock-timeout=#{config_lock_timeout}s"
60
- end
28
+ ::Kitchen::Terraform::ConfigAttributeType::Integer
29
+ .apply(
30
+ attribute: :lock_timeout,
31
+ config_attribute: self,
32
+ default_value:
33
+ lambda do
34
+ 0
35
+ end
36
+ )
61
37
  end
@@ -15,9 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
- require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_attribute_definer"
20
- require "kitchen/terraform/config_schemas/integer"
18
+ require "kitchen/terraform/config_attribute_type/integer"
21
19
 
22
20
  # This attribute controls the number of concurrent operations to use while Terraform
23
21
  # {https://www.terraform.io/docs/internals/graph.html#walking-the-graph walks the resource graph}.
@@ -26,36 +24,14 @@ require "kitchen/terraform/config_schemas/integer"
26
24
  # Required:: False
27
25
  # Default:: +10+
28
26
  # Example:: <code>parallelism: 50</code>
29
- #
30
- # @abstract It must be included by a plugin class in order to be used.
31
27
  module ::Kitchen::Terraform::ConfigAttribute::Parallelism
32
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
33
- #
34
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
35
- # @return [void]
36
- def self.included(plugin_class)
37
- ::Kitchen::Terraform::ConfigAttributeDefiner
38
- .new(
39
- attribute: self,
40
- schema: ::Kitchen::Terraform::ConfigSchemas::Integer
41
- )
42
- .define plugin_class: plugin_class
43
- end
44
-
45
- # @return [::Symbol] the symbol corresponding to the attribute.
46
- def self.to_sym
47
- :parallelism
48
- end
49
-
50
- extend ::Kitchen::Terraform::ConfigAttributeCacher
51
-
52
- # @return [::Integer] a maximum of 10 concurrent operations.
53
- def config_parallelism_default_value
54
- 10
55
- end
56
-
57
- # @return [::String] the value converted to a flag.
58
- def config_parallelism_flag
59
- "-parallelism=#{config_parallelism}"
60
- end
28
+ ::Kitchen::Terraform::ConfigAttributeType::Integer
29
+ .apply(
30
+ attribute: :parallelism,
31
+ config_attribute: self,
32
+ default_value:
33
+ lambda do
34
+ 10
35
+ end
36
+ )
61
37
  end
@@ -54,9 +54,4 @@ module ::Kitchen::Terraform::ConfigAttribute::PluginDirectory
54
54
  def config_plugin_directory_default_value
55
55
  nil
56
56
  end
57
-
58
- # @return [::String] the value converted to a flag.
59
- def config_plugin_directory_flag
60
- config_plugin_directory.nil? and "" or "-plugin-dir=#{config_plugin_directory}"
61
- end
62
57
  end
@@ -56,13 +56,4 @@ module ::Kitchen::Terraform::ConfigAttribute::VariableFiles
56
56
  def config_variable_files_default_value
57
57
  []
58
58
  end
59
-
60
- # @return [::String] the elements of the value converted to flags, joined by white space.
61
- def config_variable_files_flags
62
- config_variable_files
63
- .map do |path|
64
- "-var-file=#{path}"
65
- end
66
- .join " "
67
- end
68
59
  end
@@ -15,9 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen/terraform/config_attribute"
18
- require "kitchen/terraform/config_attribute_cacher"
19
- require "kitchen/terraform/config_attribute_definer"
20
- require "kitchen/terraform/config_schemas/hash_of_symbols_and_strings"
18
+ require "kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings"
21
19
 
22
20
  # This attribute comprises {https://www.terraform.io/docs/configuration/variables.html Terraform variables}.
23
21
  #
@@ -28,40 +26,14 @@ require "kitchen/terraform/config_schemas/hash_of_symbols_and_strings"
28
26
  # variables:
29
27
  # image: image-1234
30
28
  # zone: zone-5
31
- #
32
- # @abstract It must be included by a plugin class in order to be used.
33
29
  module ::Kitchen::Terraform::ConfigAttribute::Variables
34
- # A callback to define the configuration attribute which is invoked when this module is included in a plugin class.
35
- #
36
- # @param plugin_class [::Kitchen::Configurable] A plugin class.
37
- # @return [void]
38
- def self.included(plugin_class)
39
- ::Kitchen::Terraform::ConfigAttributeDefiner
40
- .new(
41
- attribute: self,
42
- schema: ::Kitchen::Terraform::ConfigSchemas::HashOfSymbolsAndStrings
43
- )
44
- .define plugin_class: plugin_class
45
- end
46
-
47
- # @return [::Symbol] the symbol corresponding to this attribute.
48
- def self.to_sym
49
- :variables
50
- end
51
-
52
- extend ::Kitchen::Terraform::ConfigAttributeCacher
53
-
54
- # @return [::Hash] an empty hash.
55
- def config_variables_default_value
56
- {}
57
- end
58
-
59
- # @return [::String] the elements of the value converted to flags, joined by whitespace.
60
- def config_variables_flags
61
- config_variables
62
- .map do |key, value|
63
- "-var=\"#{key}=#{value}\""
64
- end
65
- .join " "
66
- end
30
+ ::Kitchen::Terraform::ConfigAttributeType::HashOfSymbolsAndStrings
31
+ .apply(
32
+ attribute: :variables,
33
+ config_attribute: self,
34
+ default_value:
35
+ lambda do
36
+ {}
37
+ end
38
+ )
67
39
  end
@@ -14,9 +14,8 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require "kitchen"
17
+ require "kitchen/terraform"
18
18
 
19
- # This is the namespace for Test Kitchen provisioner plugins. This namespace is already defined in Test Kitchen but YARD
20
- # requires it to be redefined here in order to include documenation from the Kitchen::Terraform namespace.
21
- module Kitchen::Provisioner
19
+ # The namespace for configuration attribute types.
20
+ module ::Kitchen::Terraform::ConfigAttributeType
22
21
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2016 New Context Services, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "dry-validation"
18
+ require "kitchen/terraform/config_attribute"
19
+ require "kitchen/terraform/config_attribute_type"
20
+ require "kitchen/terraform/config_predicates/hash_of_symbols_and_strings"
21
+
22
+ # This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module which
23
+ # must be included by a plugin class.
24
+ #
25
+ # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
26
+ module ::Kitchen::Terraform::ConfigAttributeType::HashOfSymbolsAndStrings
27
+ # This method applies the configuration attribute behaviour to a module.
28
+ #
29
+ # @param attribute [::Symbol] the symbol corresponding to the configuration attribute.
30
+ # @param config_attribute [::Module] a module.
31
+ # @param default_value [::Proc] a proc which returns the default value.
32
+ # @return [self]
33
+ def self.apply(attribute:, config_attribute:, default_value:)
34
+ ::Kitchen::Terraform::ConfigAttribute
35
+ .new(
36
+ attribute: attribute,
37
+ default_value: default_value,
38
+ schema:
39
+ ::Dry::Validation
40
+ .Schema do
41
+ configure do
42
+ extend ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
43
+ end
44
+ required(:value).value :hash_of_symbols_and_strings?
45
+ end
46
+ )
47
+ .apply config_attribute: config_attribute
48
+
49
+ self
50
+ end
51
+ end