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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/kitchen/driver/terraform.rb +127 -35
- data/lib/kitchen/provisioner/terraform.rb +7 -1
- data/lib/kitchen/{verifier.rb → terraform/breaking.rb} +3 -4
- data/lib/kitchen/{driver.rb → terraform/breaking/kitchen_instance.rb} +4 -3
- data/lib/kitchen/terraform/config_attribute.rb +68 -4
- data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +10 -38
- data/lib/kitchen/terraform/config_attribute/color.rb +10 -35
- data/lib/kitchen/terraform/config_attribute/command_timeout.rb +10 -29
- data/lib/kitchen/terraform/config_attribute/groups.rb +10 -28
- data/lib/kitchen/terraform/config_attribute/lock.rb +10 -33
- data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +10 -34
- data/lib/kitchen/terraform/config_attribute/parallelism.rb +10 -34
- data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +0 -5
- data/lib/kitchen/terraform/config_attribute/variable_files.rb +0 -9
- data/lib/kitchen/terraform/config_attribute/variables.rb +10 -38
- data/lib/kitchen/{provisioner.rb → terraform/config_attribute_type.rb} +3 -4
- data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +51 -0
- data/lib/kitchen/terraform/config_attribute_type/integer.rb +47 -0
- data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +9 -0
- data/lib/kitchen/terraform/configurable.rb +11 -7
- data/lib/kitchen/terraform/{config_schemas/integer.rb → deprecating.rb} +4 -10
- data/lib/kitchen/terraform/deprecating/kitchen_instance.rb +61 -0
- data/lib/kitchen/terraform/kitchen_instance.rb +49 -0
- data/lib/kitchen/terraform/version.rb +23 -1
- data/lib/kitchen/verifier/terraform.rb +7 -1
- metadata +26 -22
- metadata.gz.sig +0 -0
- data/lib/kitchen/terraform/config_schemas/hash_of_symbols_and_strings.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f583f33eb358a79ac661e3e108e4d236f7fe4f303f9022947efb8a83b05cb1b2
|
4
|
+
data.tar.gz: 32fcb9bb51b28bb1a806d9137055edc6a27adc668906da9e4d3cbc1e0fc81daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c45754dc6cf770e90a5cf9ba2d1e664a19b3495c14a1ecb60283feac045cf0cfef916b5246a79f1f8f3b008c6e5a4ff32801465ce6ed1b056af06b465a3784be
|
7
|
+
data.tar.gz: 66af7f6b159e36b97c1c5c331dd1409b2a9143471c0be43e506a401836acfb1904fd6e8b8fb2dfae8d107d9953f395ceaef6ca2091a32319eeacc0c092b8b06e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -14,8 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
require "kitchen
|
18
|
-
require "kitchen/errors"
|
17
|
+
require "kitchen"
|
19
18
|
require "kitchen/terraform/client_version_verifier"
|
20
19
|
require "kitchen/terraform/command/output"
|
21
20
|
require "kitchen/terraform/config_attribute/backend_configurations"
|
@@ -30,6 +29,13 @@ require "kitchen/terraform/config_attribute/variable_files"
|
|
30
29
|
require "kitchen/terraform/config_attribute/variables"
|
31
30
|
require "kitchen/terraform/configurable"
|
32
31
|
require "kitchen/terraform/shell_out"
|
32
|
+
require "shellwords"
|
33
|
+
|
34
|
+
# This namespace is defined by Kitchen.
|
35
|
+
#
|
36
|
+
# @see http://www.rubydoc.info/gems/test-kitchen/Kitchen/Driver
|
37
|
+
module ::Kitchen::Driver
|
38
|
+
end
|
33
39
|
|
34
40
|
# The driver is the bridge between Test Kitchen and Terraform. It manages the
|
35
41
|
# {https://www.terraform.io/docs/state/index.html state} of the Terraform root module by shelling out and running
|
@@ -176,8 +182,6 @@ require "kitchen/terraform/shell_out"
|
|
176
182
|
class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
177
183
|
kitchen_driver_api_version 2
|
178
184
|
|
179
|
-
no_parallel_for
|
180
|
-
|
181
185
|
include ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
|
182
186
|
|
183
187
|
include ::Kitchen::Terraform::ConfigAttribute::Color
|
@@ -200,6 +204,35 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
200
204
|
|
201
205
|
include ::Kitchen::Terraform::Configurable
|
202
206
|
|
207
|
+
# This method queries for the names of the action methods which must be run in serial via a shared mutex.
|
208
|
+
#
|
209
|
+
# If the version satisfies the requirement of ~> 3.3 then no names are returned.
|
210
|
+
#
|
211
|
+
# If the version satisfies the requirement of >= 4 then +:create+, +:converge+, +:setup+, and +:destroy+ are returned.
|
212
|
+
#
|
213
|
+
# @param version [::Kitchen::Terraform::Version] the version to compare against the requirements.
|
214
|
+
# @return [::Array<Symbol>] the action method names.
|
215
|
+
def self.serial_actions(version: ::Kitchen::Terraform::Version.new)
|
216
|
+
version
|
217
|
+
.if_satisfies requirement: ::Gem::Requirement.new("~> 3.3") do
|
218
|
+
no_parallel_for
|
219
|
+
end
|
220
|
+
|
221
|
+
version
|
222
|
+
.if_satisfies requirement: ::Gem::Requirement.new(">= 4") do
|
223
|
+
super()
|
224
|
+
.empty? and
|
225
|
+
no_parallel_for(
|
226
|
+
:create,
|
227
|
+
:converge,
|
228
|
+
:setup,
|
229
|
+
:destroy
|
230
|
+
)
|
231
|
+
end
|
232
|
+
|
233
|
+
super()
|
234
|
+
end
|
235
|
+
|
203
236
|
# Applies changes to the state by selecting the test workspace, updating the dependency modules, validating the root
|
204
237
|
# module, applying the state changes, and retrieving the state output.
|
205
238
|
#
|
@@ -287,16 +320,16 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
287
320
|
.run(
|
288
321
|
command:
|
289
322
|
"apply " \
|
290
|
-
"#{
|
291
|
-
"#{
|
323
|
+
"#{lock_flag} " \
|
324
|
+
"#{lock_timeout_flag} " \
|
292
325
|
"-input=false " \
|
293
326
|
"-auto-approve=true " \
|
294
|
-
"#{
|
295
|
-
"#{
|
327
|
+
"#{color_flag} " \
|
328
|
+
"#{parallelism_flag} " \
|
296
329
|
"-refresh=true " \
|
297
|
-
"#{
|
298
|
-
"#{
|
299
|
-
"#{
|
330
|
+
"#{variables_flags} " \
|
331
|
+
"#{variable_files_flags} " \
|
332
|
+
"#{root_module_directory}",
|
300
333
|
duration: config_command_timeout,
|
301
334
|
logger: logger
|
302
335
|
)
|
@@ -306,7 +339,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
306
339
|
def apply_run_get
|
307
340
|
::Kitchen::Terraform::ShellOut
|
308
341
|
.run(
|
309
|
-
command: "get -update #{
|
342
|
+
command: "get -update #{root_module_directory}",
|
310
343
|
duration: config_command_timeout,
|
311
344
|
logger: logger
|
312
345
|
)
|
@@ -319,15 +352,29 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
319
352
|
command:
|
320
353
|
"validate " \
|
321
354
|
"-check-variables=true " \
|
322
|
-
"#{
|
323
|
-
"#{
|
324
|
-
"#{
|
325
|
-
"#{
|
355
|
+
"#{color_flag} " \
|
356
|
+
"#{variables_flags} " \
|
357
|
+
"#{variable_files_flags} " \
|
358
|
+
"#{root_module_directory}",
|
326
359
|
duration: config_command_timeout,
|
327
360
|
logger: logger
|
328
361
|
)
|
329
362
|
end
|
330
363
|
|
364
|
+
# @api private
|
365
|
+
def backend_configurations_flags
|
366
|
+
config_backend_configurations
|
367
|
+
.map do |key, value|
|
368
|
+
"-backend-config=#{::Shellwords.escape "#{key}=#{value}"}"
|
369
|
+
end
|
370
|
+
.join " "
|
371
|
+
end
|
372
|
+
|
373
|
+
# api private
|
374
|
+
def color_flag
|
375
|
+
config_color and "" or "-no-color"
|
376
|
+
end
|
377
|
+
|
331
378
|
# @api private
|
332
379
|
def create_run_init
|
333
380
|
::Kitchen::Terraform::ShellOut
|
@@ -335,18 +382,18 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
335
382
|
command:
|
336
383
|
"init " \
|
337
384
|
"-input=false " \
|
338
|
-
"#{
|
339
|
-
"#{
|
340
|
-
"#{
|
385
|
+
"#{lock_flag} " \
|
386
|
+
"#{lock_timeout_flag} " \
|
387
|
+
"#{color_flag} " \
|
341
388
|
"-upgrade " \
|
342
389
|
"-force-copy " \
|
343
390
|
"-backend=true " \
|
344
|
-
"#{
|
391
|
+
"#{backend_configurations_flags} " \
|
345
392
|
"-get=true " \
|
346
393
|
"-get-plugins=true " \
|
347
|
-
"#{
|
394
|
+
"#{plugin_directory_flag} " \
|
348
395
|
"-verify-plugins=true " \
|
349
|
-
"#{
|
396
|
+
"#{root_module_directory}",
|
350
397
|
duration: config_command_timeout,
|
351
398
|
logger: logger
|
352
399
|
)
|
@@ -359,15 +406,15 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
359
406
|
command:
|
360
407
|
"destroy " \
|
361
408
|
"-force " \
|
362
|
-
"#{
|
363
|
-
"#{
|
409
|
+
"#{lock_flag} " \
|
410
|
+
"#{lock_timeout_flag} " \
|
364
411
|
"-input=false " \
|
365
|
-
"#{
|
366
|
-
"#{
|
412
|
+
"#{color_flag} " \
|
413
|
+
"#{parallelism_flag} " \
|
367
414
|
"-refresh=true " \
|
368
|
-
"#{
|
369
|
-
"#{
|
370
|
-
"#{
|
415
|
+
"#{variables_flags} " \
|
416
|
+
"#{variable_files_flags} " \
|
417
|
+
"#{root_module_directory}",
|
371
418
|
duration: config_command_timeout,
|
372
419
|
logger: logger
|
373
420
|
)
|
@@ -380,17 +427,17 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
380
427
|
command:
|
381
428
|
"init " \
|
382
429
|
"-input=false " \
|
383
|
-
"#{
|
384
|
-
"#{
|
385
|
-
"#{
|
430
|
+
"#{lock_flag} " \
|
431
|
+
"#{lock_timeout_flag} " \
|
432
|
+
"#{color_flag} " \
|
386
433
|
"-force-copy " \
|
387
434
|
"-backend=true " \
|
388
|
-
"#{
|
435
|
+
"#{backend_configurations_flags} " \
|
389
436
|
"-get=true " \
|
390
437
|
"-get-plugins=true " \
|
391
|
-
"#{
|
438
|
+
"#{plugin_directory_flag} " \
|
392
439
|
"-verify-plugins=true " \
|
393
|
-
"#{
|
440
|
+
"#{root_module_directory}",
|
394
441
|
duration: config_command_timeout,
|
395
442
|
logger: logger
|
396
443
|
)
|
@@ -421,6 +468,33 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
421
468
|
@instance_name ||= instance.name
|
422
469
|
end
|
423
470
|
|
471
|
+
# @api private
|
472
|
+
def lock_flag
|
473
|
+
"-lock=#{config_lock}"
|
474
|
+
end
|
475
|
+
|
476
|
+
# @api private
|
477
|
+
def lock_timeout_flag
|
478
|
+
"-lock-timeout=#{config_lock_timeout}s"
|
479
|
+
end
|
480
|
+
|
481
|
+
# @api private
|
482
|
+
def parallelism_flag
|
483
|
+
"-parallelism=#{config_parallelism}"
|
484
|
+
end
|
485
|
+
|
486
|
+
# @api private
|
487
|
+
def plugin_directory_flag
|
488
|
+
config_plugin_directory and
|
489
|
+
"-plugin-dir=#{::Shellwords.escape config_plugin_directory}" or
|
490
|
+
""
|
491
|
+
end
|
492
|
+
|
493
|
+
# @api private
|
494
|
+
def root_module_directory
|
495
|
+
::Shellwords.escape config_root_module_directory
|
496
|
+
end
|
497
|
+
|
424
498
|
# @api private
|
425
499
|
def run_workspace_select_instance
|
426
500
|
::Kitchen::Terraform::ShellOut
|
@@ -437,4 +511,22 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
|
|
437
511
|
logger: logger
|
438
512
|
)
|
439
513
|
end
|
514
|
+
|
515
|
+
# @api private
|
516
|
+
def variable_files_flags
|
517
|
+
config_variable_files
|
518
|
+
.map do |path|
|
519
|
+
"-var-file=#{::Shellwords.escape path}"
|
520
|
+
end
|
521
|
+
.join " "
|
522
|
+
end
|
523
|
+
|
524
|
+
# @api private
|
525
|
+
def variables_flags
|
526
|
+
config_variables
|
527
|
+
.map do |key, value|
|
528
|
+
"-var=#{::Shellwords.escape "#{key}=#{value}"}"
|
529
|
+
end
|
530
|
+
.join " "
|
531
|
+
end
|
440
532
|
end
|
@@ -14,10 +14,16 @@
|
|
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"
|
18
18
|
require "kitchen/terraform/configurable"
|
19
19
|
require "kitchen/terraform/error"
|
20
20
|
|
21
|
+
# This namespace is defined by Kitchen.
|
22
|
+
#
|
23
|
+
# @see http://www.rubydoc.info/gems/test-kitchen/Kitchen/Provisioner
|
24
|
+
module ::Kitchen::Provisioner
|
25
|
+
end
|
26
|
+
|
21
27
|
# The provisioner utilizes the driver to apply changes to the Terraform state in order to reach the desired
|
22
28
|
# configuration of the root module.
|
23
29
|
#
|
@@ -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
|
-
#
|
20
|
-
|
21
|
-
module Kitchen::Verifier
|
19
|
+
# The namespace for objects with breaking changes.
|
20
|
+
module ::Kitchen::Terraform::Breaking
|
22
21
|
end
|
@@ -14,9 +14,10 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require "delegate"
|
17
18
|
require "kitchen"
|
19
|
+
require "kitchen/terraform/breaking"
|
18
20
|
|
19
|
-
# This
|
20
|
-
|
21
|
-
module Kitchen::Driver
|
21
|
+
# This class provides the breaking change to the KitchenInstance.
|
22
|
+
class ::Kitchen::Terraform::Breaking::KitchenInstance < DelegateClass ::Kitchen::Instance
|
22
23
|
end
|
@@ -15,9 +15,73 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require "kitchen/terraform"
|
18
|
+
require "kitchen/terraform/config_attribute_cacher"
|
19
|
+
require "kitchen/terraform/config_attribute_definer"
|
18
20
|
|
19
|
-
#
|
20
|
-
|
21
|
-
#
|
22
|
-
|
21
|
+
# This class applies the behaviour of a configuration attribute to a module which must be included by a plugin class.
|
22
|
+
class ::Kitchen::Terraform::ConfigAttribute
|
23
|
+
# This method applies the configuration attribute behaviour to a module.
|
24
|
+
#
|
25
|
+
# @param config_attribute [::Module] a module.
|
26
|
+
# @return [self]
|
27
|
+
def apply(config_attribute:)
|
28
|
+
self.config_attribute = config_attribute
|
29
|
+
define_singleton_included
|
30
|
+
define_singleton_to_sym
|
31
|
+
define_config_attribute_default_value
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_accessor(
|
38
|
+
:attribute,
|
39
|
+
:config_attribute,
|
40
|
+
:default_value,
|
41
|
+
:schema
|
42
|
+
)
|
43
|
+
|
44
|
+
# @api private
|
45
|
+
def define_config_attribute_default_value
|
46
|
+
config_attribute
|
47
|
+
.send(
|
48
|
+
:define_method,
|
49
|
+
"config_#{attribute}_default_value",
|
50
|
+
&default_value
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @api private
|
55
|
+
def define_singleton_included
|
56
|
+
local_schema = schema
|
57
|
+
|
58
|
+
config_attribute
|
59
|
+
.define_singleton_method :included do |plugin_class|
|
60
|
+
::Kitchen::Terraform::ConfigAttributeDefiner
|
61
|
+
.new(
|
62
|
+
attribute: self,
|
63
|
+
schema: local_schema
|
64
|
+
)
|
65
|
+
.define plugin_class: plugin_class
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# @api private
|
70
|
+
def define_singleton_to_sym
|
71
|
+
local_attribute = attribute
|
72
|
+
|
73
|
+
config_attribute
|
74
|
+
.define_singleton_method :to_sym do
|
75
|
+
local_attribute
|
76
|
+
end
|
77
|
+
|
78
|
+
config_attribute.extend ::Kitchen::Terraform::ConfigAttributeCacher
|
79
|
+
end
|
80
|
+
|
81
|
+
# @api private
|
82
|
+
def initialize(attribute:, default_value:, schema:)
|
83
|
+
self.attribute = attribute
|
84
|
+
self.default_value = default_value
|
85
|
+
self.schema = schema
|
86
|
+
end
|
23
87
|
end
|
@@ -15,9 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require "kitchen/terraform/config_attribute"
|
18
|
-
require "kitchen/terraform/
|
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/backends/config.html Terraform backend configuration}
|
23
21
|
# arguments to complete a
|
@@ -30,40 +28,14 @@ require "kitchen/terraform/config_schemas/hash_of_symbols_and_strings"
|
|
30
28
|
# backend_configurations:
|
31
29
|
# address: demo.consul.io
|
32
30
|
# path: example_app/terraform_state
|
33
|
-
#
|
34
|
-
# @abstract It must be included by a plugin class in order to be used.
|
35
31
|
module ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
:backend_configurations
|
52
|
-
end
|
53
|
-
|
54
|
-
extend ::Kitchen::Terraform::ConfigAttributeCacher
|
55
|
-
|
56
|
-
# @return [::Hash] an empty hash.
|
57
|
-
def config_backend_configurations_default_value
|
58
|
-
{}
|
59
|
-
end
|
60
|
-
|
61
|
-
# @return [::String] the elements of the value converted to flags, joined by white space.
|
62
|
-
def config_backend_configurations_flags
|
63
|
-
config_backend_configurations
|
64
|
-
.map do |key, value|
|
65
|
-
"-backend-config=\"#{key}=#{value}\""
|
66
|
-
end
|
67
|
-
.join " "
|
68
|
-
end
|
32
|
+
::Kitchen::Terraform::ConfigAttributeType::HashOfSymbolsAndStrings
|
33
|
+
.apply(
|
34
|
+
attribute: :backend_configurations,
|
35
|
+
config_attribute: self,
|
36
|
+
default_value:
|
37
|
+
lambda do
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
)
|
69
41
|
end
|