kitchen-terraform 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) 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 +15 -12
  5. data/lib/kitchen/terraform/command/output.rb +5 -11
  6. data/lib/kitchen/terraform/config_attribute.rb +10 -13
  7. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +3 -4
  8. data/lib/kitchen/terraform/config_attribute/client.rb +69 -0
  9. data/lib/kitchen/terraform/config_attribute/color.rb +5 -7
  10. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +3 -4
  11. data/lib/kitchen/terraform/config_attribute/lock.rb +5 -7
  12. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +3 -4
  13. data/lib/kitchen/terraform/config_attribute/parallelism.rb +3 -4
  14. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +2 -3
  15. data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +2 -3
  16. data/lib/kitchen/terraform/config_attribute/variable_files.rb +2 -3
  17. data/lib/kitchen/terraform/config_attribute/variables.rb +3 -4
  18. data/lib/kitchen/terraform/config_attribute_definer.rb +11 -14
  19. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +8 -10
  20. data/lib/kitchen/terraform/config_attribute_type/integer.rb +5 -7
  21. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +7 -7
  22. data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +6 -6
  23. data/lib/kitchen/terraform/config_schemas/boolean.rb +2 -2
  24. data/lib/kitchen/terraform/config_schemas/optional_string.rb +6 -6
  25. data/lib/kitchen/terraform/config_schemas/string.rb +2 -2
  26. data/lib/kitchen/terraform/configurable.rb +9 -21
  27. data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +1 -1
  28. data/lib/kitchen/terraform/shell_out.rb +12 -16
  29. data/lib/kitchen/terraform/version.rb +1 -1
  30. data/lib/kitchen/verifier/terraform.rb +4 -37
  31. metadata +51 -36
  32. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 272bfd39d809ace18838162e11c8488a6ae6623a6c88dc1b177619b41007e95c
4
- data.tar.gz: d2509795935a5daccf9ee2be3521f0ac7f72865a8be5f3c430a008dd4623bb83
3
+ metadata.gz: 8ea1afc210ba60f866e551ce195c076eda236fcba4ddbfd0e6c8198583243e13
4
+ data.tar.gz: 27665fd25ff0b67acc1df2a2d3febf69353ed3c166790a515bb2dee37eee807b
5
5
  SHA512:
6
- metadata.gz: 4be878740914aa1fe71c61d895747840ada06b414211c65ff89f01aa7a9b9bd5128800fc82285b8aee024704c21f1cb8500002dcc2460624b1cf25a8e3ca222c
7
- data.tar.gz: f66253b088954ad0c4a545daa7b7cd24bdffa271cf34b613bb95c73973ff72bedc365abdfacc7be6c0329ba90f8674bf9d442202cf7b97f840b3124e45b66600
6
+ metadata.gz: '08243c47d3406c442d5eb64625667affa29c20fb90f5558124678d74a46239d49537ccd8361d15b42d6125f08849eae1c55871edbe768bd1a0696e7c0a772000'
7
+ data.tar.gz: ee74fa4d72efc97e01faaed3f941e78cb075b4fe7a4e8a9212176d3ac957d7e4749ce988bb056ad44d62d37b8b8949cc9764f538390e8fb97f61132f0ff6ca1b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -18,6 +18,7 @@ require "kitchen"
18
18
  require "kitchen/terraform/command/output"
19
19
  require "kitchen/terraform/command/version"
20
20
  require "kitchen/terraform/config_attribute/backend_configurations"
21
+ require "kitchen/terraform/config_attribute/client"
21
22
  require "kitchen/terraform/config_attribute/color"
22
23
  require "kitchen/terraform/config_attribute/command_timeout"
23
24
  require "kitchen/terraform/config_attribute/lock"
@@ -32,7 +33,6 @@ require "kitchen/terraform/configurable"
32
33
  require "kitchen/terraform/shell_out"
33
34
  require "kitchen/terraform/verify_version"
34
35
  require "shellwords"
35
- require "tty/which"
36
36
 
37
37
  # This namespace is defined by Kitchen.
38
38
  #
@@ -198,6 +198,8 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
198
198
 
199
199
  include ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
200
200
 
201
+ include ::Kitchen::Terraform::ConfigAttribute::Client
202
+
201
203
  include ::Kitchen::Terraform::ConfigAttribute::Color
202
204
 
203
205
  include ::Kitchen::Terraform::ConfigAttribute::CommandTimeout
@@ -272,6 +274,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
272
274
  def retrieve_outputs(&block)
273
275
  run_workspace_select_instance
274
276
  ::Kitchen::Terraform::Command::Output.run(
277
+ client: config_client,
275
278
  options: {
276
279
  cwd: config_root_module_directory, live_stream: logger, timeout: config_command_timeout,
277
280
  }, &block
@@ -280,16 +283,6 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
280
283
  raise ::Kitchen::ActionFailed, error.message
281
284
  end
282
285
 
283
- # Verifies that the Terraform CLI is on the PATH.
284
- #
285
- # @raise [::Kitchen::UserError] if the Terraform CLI is not available.
286
- # @return [void]
287
- def verify_dependencies
288
- if !::TTY::Which.exist? "terraform"
289
- raise ::Kitchen::UserError, "The Terraform CLI was not found on the PATH"
290
- end
291
- end
292
-
293
286
  private
294
287
 
295
288
  def apply_run
@@ -301,6 +294,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
301
294
  # @api private
302
295
  def apply_run_apply
303
296
  ::Kitchen::Terraform::ShellOut.run(
297
+ client: config_client,
304
298
  command: "apply " \
305
299
  "#{lock_flag} " \
306
300
  "#{lock_timeout_flag} " \
@@ -322,6 +316,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
322
316
  # @api private
323
317
  def apply_run_get
324
318
  ::Kitchen::Terraform::ShellOut.run(
319
+ client: config_client,
325
320
  command: "get -update",
326
321
  options: {
327
322
  cwd: config_root_module_directory,
@@ -334,6 +329,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
334
329
  # @api private
335
330
  def apply_run_validate
336
331
  ::Kitchen::Terraform::ShellOut.run(
332
+ client: config_client,
337
333
  command: "validate " \
338
334
  "#{color_flag} " \
339
335
  "#{variables_flags} " \
@@ -361,6 +357,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
361
357
  # @api private
362
358
  def create_run_init
363
359
  ::Kitchen::Terraform::ShellOut.run(
360
+ client: config_client,
364
361
  command: "init " \
365
362
  "-input=false " \
366
363
  "#{lock_flag} " \
@@ -385,6 +382,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
385
382
  # @api private
386
383
  def destroy_run_destroy
387
384
  ::Kitchen::Terraform::ShellOut.run(
385
+ client: config_client,
388
386
  command: "destroy " \
389
387
  "-auto-approve " \
390
388
  "#{lock_flag} " \
@@ -397,7 +395,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
397
395
  "#{variable_files_flags}",
398
396
  options: {
399
397
  cwd: config_root_module_directory,
400
- environment: {"TF_WARN_OUTPUT_ERRORS" => "true"},
398
+ environment: { "TF_WARN_OUTPUT_ERRORS" => "true" },
401
399
  live_stream: logger,
402
400
  timeout: config_command_timeout,
403
401
  },
@@ -407,6 +405,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
407
405
  # @api private
408
406
  def destroy_run_init
409
407
  ::Kitchen::Terraform::ShellOut.run(
408
+ client: config_client,
410
409
  command: "init " \
411
410
  "-input=false " \
412
411
  "#{lock_flag} " \
@@ -430,6 +429,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
430
429
  # @api private
431
430
  def destroy_run_workspace_delete_instance
432
431
  ::Kitchen::Terraform::ShellOut.run(
432
+ client: config_client,
433
433
  command: "workspace delete #{workspace_name}",
434
434
  options: {
435
435
  cwd: config_root_module_directory,
@@ -442,6 +442,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
442
442
  # @api private
443
443
  def destroy_run_workspace_select_default
444
444
  ::Kitchen::Terraform::ShellOut.run(
445
+ client: config_client,
445
446
  command: "workspace select default",
446
447
  options: {
447
448
  cwd: config_root_module_directory,
@@ -478,6 +479,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
478
479
  # @api private
479
480
  def run_workspace_select_instance
480
481
  ::Kitchen::Terraform::ShellOut.run(
482
+ client: config_client,
481
483
  command: "workspace select #{workspace_name}",
482
484
  options: {
483
485
  cwd: config_root_module_directory,
@@ -487,6 +489,7 @@ class ::Kitchen::Driver::Terraform < ::Kitchen::Driver::Base
487
489
  )
488
490
  rescue ::Kitchen::Terraform::Error
489
491
  ::Kitchen::Terraform::ShellOut.run(
492
+ client: config_client,
490
493
  command: "workspace new #{workspace_name}",
491
494
  options: {
492
495
  cwd: config_root_module_directory,
@@ -29,13 +29,11 @@ module ::Kitchen::Terraform::Command::Output
29
29
  # @option options [::Kitchen::Logger] :live_stream a Test Kitchen logger to capture the output from running the
30
30
  # command.
31
31
  # @option options [::Integer] :timeout the maximum duration in seconds to run the command.
32
+ # @param client [::String] the pathname of the Terraform client.
32
33
  # @param options [::Hash] options which adjust the execution of the command.
33
34
  # @yieldparam output [::Hash] the standard output of the command parsed as JSON.
34
- def run(options:, &block)
35
- run_shell_out(
36
- options: options,
37
- &block
38
- )
35
+ def run(client:, options:, &block)
36
+ run_shell_out client: client, options: options, &block
39
37
  rescue ::JSON::ParserError => error
40
38
  handle_json_parser error: error
41
39
  rescue ::Kitchen::Terraform::Error => error
@@ -62,12 +60,8 @@ module ::Kitchen::Terraform::Command::Output
62
60
  end
63
61
 
64
62
  # @api private
65
- def run_shell_out(options:)
66
- ::Kitchen::Terraform::ShellOut
67
- .run(
68
- command: "output -json",
69
- options: options,
70
- ) do |standard_output:|
63
+ def run_shell_out(client:, options:)
64
+ ::Kitchen::Terraform::ShellOut.run client: client, command: "output -json", options: options do |standard_output:|
71
65
  yield outputs: ::JSON.parse(standard_output)
72
66
  end
73
67
  end
@@ -55,25 +55,22 @@ class ::Kitchen::Terraform::ConfigAttribute
55
55
  def define_singleton_included
56
56
  local_schema = schema
57
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
58
+ config_attribute.define_singleton_method :included do |plugin_class|
59
+ ::Kitchen::Terraform::ConfigAttributeDefiner
60
+ .new(
61
+ attribute: self,
62
+ schema: local_schema,
63
+ ).define plugin_class: plugin_class
64
+ end
67
65
  end
68
66
 
69
67
  # @api private
70
68
  def define_singleton_to_sym
71
69
  local_attribute = attribute
72
70
 
73
- config_attribute
74
- .define_singleton_method :to_sym do
75
- local_attribute
76
- end
71
+ config_attribute.define_singleton_method :to_sym do
72
+ local_attribute
73
+ end
77
74
 
78
75
  config_attribute.extend ::Kitchen::Terraform::ConfigAttributeCacher
79
76
  end
@@ -33,9 +33,8 @@ module ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
33
33
  .apply(
34
34
  attribute: :backend_configurations,
35
35
  config_attribute: self,
36
- default_value:
37
- lambda do
38
- {}
39
- end
36
+ default_value: lambda do
37
+ {}
38
+ end,
40
39
  )
41
40
  end
@@ -0,0 +1,69 @@
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 "kitchen/terraform/config_attribute_cacher"
18
+ require "kitchen/terraform/config_schemas/string"
19
+ require "kitchen/terraform/config_attribute_definer"
20
+ require "tty/which"
21
+
22
+ module Kitchen
23
+ module Terraform
24
+ class ConfigAttribute
25
+ # This attribute contains the pathname of the
26
+ # {https://www.terraform.io/docs/commands/index.html Terraform client} to be used by Kitchen-Terraform.
27
+ #
28
+ # If the value is not an absolute pathname or a relative pathname then Kitchen-Terraform will attempt to find the
29
+ # value in the directories of the {https://en.wikipedia.org/wiki/PATH_(variable) PATH}.
30
+ #
31
+ # The pathname of any executable file which implements the interfaces of the following Terraform client commands
32
+ # may be specified: apply; destroy; get; init; validate; workspace.
33
+ #
34
+ # Type:: {http://www.yaml.org/spec/1.2/spec.html#id2760844 Scalar}
35
+ # Required:: False
36
+ # Default:: <code>terraform</code>
37
+ # Example:: <code>client: /usr/local/bin/terraform</code>
38
+ # Example:: <code>client: ./bin/terraform</code>
39
+ # Example:: <code>client: terraform</code>
40
+ #
41
+ # @abstract It must be included by a plugin class in order to be used.
42
+ module Client
43
+ class << self
44
+ def included(plugin_class)
45
+ ::Kitchen::Terraform::ConfigAttributeDefiner.new(
46
+ attribute: self,
47
+ schema: ::Kitchen::Terraform::ConfigSchemas::String,
48
+ ).define plugin_class: plugin_class
49
+ plugin_class.expand_path_for to_sym do |plugin|
50
+ !::TTY::Which.exist? plugin[to_sym]
51
+ end
52
+ end
53
+
54
+ # @return [::Symbol] the symbol corresponding to this attribute.
55
+ def to_sym
56
+ :client
57
+ end
58
+ end
59
+
60
+ extend ::Kitchen::Terraform::ConfigAttributeCacher
61
+
62
+ # @return [::String] </code>"terraform"</code>
63
+ def config_client_default_value
64
+ "terraform"
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -32,11 +32,9 @@ module ::Kitchen::Terraform::ConfigAttribute::Color
32
32
  ::Kitchen::Terraform::ConfigAttribute
33
33
  .new(
34
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
35
+ default_value: lambda do
36
+ ::Kitchen.tty?
37
+ end,
38
+ schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
39
+ ).apply config_attribute: self
42
40
  end
@@ -28,9 +28,8 @@ module ::Kitchen::Terraform::ConfigAttribute::CommandTimeout
28
28
  .apply(
29
29
  attribute: :command_timeout,
30
30
  config_attribute: self,
31
- default_value:
32
- lambda do
33
- 600
34
- end
31
+ default_value: lambda do
32
+ 600
33
+ end,
35
34
  )
36
35
  end
@@ -28,11 +28,9 @@ module ::Kitchen::Terraform::ConfigAttribute::Lock
28
28
  ::Kitchen::Terraform::ConfigAttribute
29
29
  .new(
30
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
31
+ default_value: lambda do
32
+ true
33
+ end,
34
+ schema: ::Kitchen::Terraform::ConfigSchemas::Boolean,
35
+ ).apply config_attribute: self
38
36
  end
@@ -29,9 +29,8 @@ module ::Kitchen::Terraform::ConfigAttribute::LockTimeout
29
29
  .apply(
30
30
  attribute: :lock_timeout,
31
31
  config_attribute: self,
32
- default_value:
33
- lambda do
34
- 0
35
- end
32
+ default_value: lambda do
33
+ 0
34
+ end,
36
35
  )
37
36
  end
@@ -29,9 +29,8 @@ module ::Kitchen::Terraform::ConfigAttribute::Parallelism
29
29
  .apply(
30
30
  attribute: :parallelism,
31
31
  config_attribute: self,
32
- default_value:
33
- lambda do
34
- 10
35
- end
32
+ default_value: lambda do
33
+ 10
34
+ end,
36
35
  )
37
36
  end
@@ -38,9 +38,8 @@ module ::Kitchen::Terraform::ConfigAttribute::PluginDirectory
38
38
  ::Kitchen::Terraform::FilePathConfigAttributeDefiner
39
39
  .new(
40
40
  attribute: self,
41
- schema: ::Kitchen::Terraform::ConfigSchemas::OptionalString
42
- )
43
- .define plugin_class: plugin_class
41
+ schema: ::Kitchen::Terraform::ConfigSchemas::OptionalString,
42
+ ).define plugin_class: plugin_class
44
43
  end
45
44
 
46
45
  # @return [::Symbol] the symbol corresponding to this attribute.
@@ -36,9 +36,8 @@ module ::Kitchen::Terraform::ConfigAttribute::RootModuleDirectory
36
36
  ::Kitchen::Terraform::FilePathConfigAttributeDefiner
37
37
  .new(
38
38
  attribute: self,
39
- schema: ::Kitchen::Terraform::ConfigSchemas::String
40
- )
41
- .define plugin_class: plugin_class
39
+ schema: ::Kitchen::Terraform::ConfigSchemas::String,
40
+ ).define plugin_class: plugin_class
42
41
  end
43
42
 
44
43
  # @return [::Symbol] the symbol corresponding to the attribute.
@@ -40,9 +40,8 @@ module ::Kitchen::Terraform::ConfigAttribute::VariableFiles
40
40
  ::Kitchen::Terraform::FilePathConfigAttributeDefiner
41
41
  .new(
42
42
  attribute: self,
43
- schema: ::Kitchen::Terraform::ConfigSchemas::ArrayOfStrings
44
- )
45
- .define plugin_class: plugin_class
43
+ schema: ::Kitchen::Terraform::ConfigSchemas::ArrayOfStrings,
44
+ ).define plugin_class: plugin_class
46
45
  end
47
46
 
48
47
  # @return [::Symbol] the symbol corresponding to this attribute.
@@ -31,9 +31,8 @@ module ::Kitchen::Terraform::ConfigAttribute::Variables
31
31
  .apply(
32
32
  attribute: :variables,
33
33
  config_attribute: self,
34
- default_value:
35
- lambda do
36
- {}
37
- end
34
+ default_value: lambda do
35
+ {}
36
+ end,
38
37
  )
39
38
  end
@@ -23,20 +23,17 @@ class ::Kitchen::Terraform::ConfigAttributeDefiner
23
23
  # @param plugin_class [::Kitchen::Configurable] a plugin class.
24
24
  # @return [void]
25
25
  def define(plugin_class:)
26
- plugin_class
27
- .required_config @attribute do |_attribute, value, _plugin|
28
- process(
29
- messages:
30
- @schema
31
- .call(value: value)
32
- .messages,
33
- plugin_class: plugin_class
34
- )
35
- end
36
- plugin_class
37
- .default_config @attribute do |plugin|
38
- plugin.send "config_#{@attribute}_default_value"
39
- end
26
+ plugin_class.required_config @attribute do |_attribute, value, _plugin|
27
+ process(
28
+ messages: @schema
29
+ .call(value: value)
30
+ .messages,
31
+ plugin_class: plugin_class,
32
+ )
33
+ end
34
+ plugin_class.default_config @attribute do |plugin|
35
+ plugin.send "config_#{@attribute}_default_value"
36
+ end
40
37
  end
41
38
 
42
39
  private
@@ -35,16 +35,14 @@ module ::Kitchen::Terraform::ConfigAttributeType::HashOfSymbolsAndStrings
35
35
  .new(
36
36
  attribute: attribute,
37
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
38
+ schema: ::Dry::Validation
39
+ .Schema do
40
+ configure do
41
+ extend ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
42
+ end
43
+ required(:value).value :hash_of_symbols_and_strings?
44
+ end,
45
+ ).apply config_attribute: config_attribute
48
46
 
49
47
  self
50
48
  end
@@ -34,13 +34,11 @@ module ::Kitchen::Terraform::ConfigAttributeType::Integer
34
34
  .new(
35
35
  attribute: attribute,
36
36
  default_value: default_value,
37
- schema:
38
- ::Dry::Validation
39
- .Schema do
40
- required(:value).filled :int?
41
- end
42
- )
43
- .apply config_attribute: config_attribute
37
+ schema: ::Dry::Validation
38
+ .Schema do
39
+ required(:value).filled :int?
40
+ end,
41
+ ).apply config_attribute: config_attribute
44
42
 
45
43
  self
46
44
  end
@@ -50,8 +50,8 @@ module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
50
50
  def self.all_symbols?(keys:)
51
51
  keys
52
52
  .all? do |key|
53
- key.kind_of? ::Symbol
54
- end
53
+ key.kind_of? ::Symbol
54
+ end
55
55
  end
56
56
 
57
57
  # If all values are strings then the result is +true+; else the result is +false+.
@@ -62,8 +62,8 @@ module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
62
62
  def self.all_strings?(values:)
63
63
  values
64
64
  .all? do |value|
65
- value.kind_of? ::String
66
- end
65
+ value.kind_of? ::String
66
+ end
67
67
  end
68
68
 
69
69
  private
@@ -73,9 +73,9 @@ module ::Kitchen::Terraform::ConfigPredicates::HashOfSymbolsAndStrings
73
73
  .merge(
74
74
  en: {
75
75
  errors: {
76
- hash_of_symbols_and_strings?: "must be a hash which includes only symbol keys and string values"
77
- }
78
- }
76
+ hash_of_symbols_and_strings?: "must be a hash which includes only symbol keys and string values",
77
+ },
78
+ },
79
79
  )
80
80
  end
81
81
  end
@@ -23,9 +23,9 @@ require "kitchen/terraform/config_schemas"
23
23
  ::Kitchen::Terraform::ConfigSchemas::ArrayOfStrings =
24
24
  ::Dry::Validation
25
25
  .Schema do
26
- required(:value)
27
- .each(
28
- :filled?,
29
- :str?
30
- )
31
- end
26
+ required(:value)
27
+ .each(
28
+ :filled?,
29
+ :str?
30
+ )
31
+ end
@@ -23,5 +23,5 @@ require "kitchen/terraform/config_schemas"
23
23
  ::Kitchen::Terraform::ConfigSchemas::Boolean =
24
24
  ::Dry::Validation
25
25
  .Schema do
26
- required(:value).filled :bool?
27
- end
26
+ required(:value).filled :bool?
27
+ end
@@ -23,9 +23,9 @@ require "kitchen/terraform/config_schemas"
23
23
  ::Kitchen::Terraform::ConfigSchemas::OptionalString =
24
24
  ::Dry::Validation
25
25
  .Schema do
26
- required(:value)
27
- .maybe(
28
- :str?,
29
- :filled?
30
- )
31
- end
26
+ required(:value)
27
+ .maybe(
28
+ :str?,
29
+ :filled?
30
+ )
31
+ end
@@ -22,5 +22,5 @@ require "kitchen/terraform/config_schemas"
22
22
  ::Kitchen::Terraform::ConfigSchemas::String =
23
23
  ::Dry::Validation
24
24
  .Schema do
25
- required(:value).filled :str?
26
- end
25
+ required(:value).filled :str?
26
+ end
@@ -30,27 +30,15 @@ module ::Kitchen::Terraform::Configurable
30
30
  self
31
31
  end
32
32
 
33
- # Alternative implementation of Kitchen::Configurable#finalize_config! which validates the configuration before
34
- # attempting to expand paths.
35
- #
36
- # @note this method should be removed when Test Kitchen: Issue #1229 is solved.
37
- # @param kitchen_instance [::Kitchen::Instance] an associated Test Kitchen instance.
38
- # @return [self] itself, for use in chaining.
39
- # @raise [::Kitchen::ClientError] if the instance is nil.
40
- # @see https://github.com/test-kitchen/test-kitchen/blob/v1.16.0/lib/kitchen/configurable.rb#L46
41
- # Kitchen::Configurable#finalize_config!
42
- # @see https://github.com/test-kitchen/test-kitchen/issues/1229 Test Kitchen: Issue #1229
43
- def finalize_config!(kitchen_instance)
44
- kitchen_instance or
45
- raise(
46
- ::Kitchen::ClientError,
47
- "Instance must be provided to #{self}"
48
- )
33
+ private
49
34
 
50
- @instance = kitchen_instance
51
- validate_config!
52
- expand_paths!
53
- load_needed_dependencies!
54
- self
35
+ def expand_paths!
36
+ validate_config! if !@validate_config_called
37
+ super
38
+ end
39
+
40
+ def validate_config!
41
+ @validate_config_called ||= true
42
+ super
55
43
  end
56
44
  end
@@ -42,7 +42,7 @@ class ::Kitchen::Terraform::FilePathConfigAttributeDefiner
42
42
  ::Kitchen::Terraform::ConfigAttributeDefiner
43
43
  .new(
44
44
  attribute: attribute,
45
- schema: schema
45
+ schema: schema,
46
46
  )
47
47
  end
48
48
  end
@@ -26,28 +26,24 @@ require "mixlib/shellout"
26
26
  module ::Kitchen::Terraform::ShellOut
27
27
  # Runs a Terraform command.
28
28
  #
29
- # @option options [::String] :cwd the directory in which to run the command.
29
+ # @option options [::Hash] :environment environment variables to define when running the command.
30
+ # @option options [::Integer] :timeout the maximum duration in seconds to run the command.
30
31
  # @option options [::Kitchen::Logger] :live_stream a Test Kitchen logger to capture the output from running the
31
32
  # command.
32
- # @option options [::Integer] :timeout the maximum duration in seconds to run the command.
33
+ # @option options [::String] :cwd the directory in which to run the command.
34
+ # @param client [::String] the pathname of the Terraform client.
33
35
  # @param command [::String] the command to run.
34
- # @option options [::Hash] :environment environment variables to define when running the command.
35
36
  # @param options [::Hash] options which adjust the execution of the command.
36
37
  # @raise [::Kitchen::Terraform::Error] if running the command fails.
37
38
  # @return [::String] the standard output from running the command.
38
39
  # @see https://rubygems.org/gems/mixlib-shellout mixlib-shellout
39
40
  # @yieldparam standard_output [::String] the standard output from running the command.
40
- def self.run(command:, options:, &block)
41
- block ||=
42
- lambda do |standard_output:|
43
- standard_output
44
- end
41
+ def self.run(client:, command:, options:, &block)
42
+ block ||= lambda do |standard_output:|
43
+ standard_output
44
+ end
45
45
 
46
- run_shell_out(
47
- command: command,
48
- options: options,
49
- &block
50
- )
46
+ run_shell_out client: client, command: command, options: options, &block
51
47
  rescue ::Errno::EACCES,
52
48
  ::Errno::ENOENT,
53
49
  ::Mixlib::ShellOut::InvalidCommandOption,
@@ -67,11 +63,11 @@ module ::Kitchen::Terraform::ShellOut
67
63
  end
68
64
 
69
65
  # @api private
70
- def self.run_shell_out(command:, options:)
66
+ def self.run_shell_out(client:, command:, options:)
71
67
  yield(standard_output: ::Mixlib::ShellOut.new(
72
- "terraform #{command}",
68
+ "#{client} #{command}",
73
69
  options.merge(
74
- environment: {"TF_IN_AUTOMATION" => "true", "TF_WARN_OUTPUT_ERRORS" => "1"}.merge(
70
+ environment: { "TF_IN_AUTOMATION" => "true", "TF_WARN_OUTPUT_ERRORS" => "1" }.merge(
75
71
  options.fetch(:environment) do
76
72
  {}
77
73
  end
@@ -72,7 +72,7 @@ module ::Kitchen::Terraform::Version
72
72
 
73
73
  # @api private
74
74
  def value
75
- self.value = ::Gem::Version.new "4.3.0" if not @value
75
+ self.value = ::Gem::Version.new "4.4.0" if not @value
76
76
  @value
77
77
  end
78
78
 
@@ -106,31 +106,12 @@ module Kitchen
106
106
  # @return [self]
107
107
  def finalize_config!(kitchen_instance)
108
108
  super kitchen_instance
109
- configure_inspec_connection_options
110
- configure_inspec_miscellaneous_options
111
- end
112
-
113
- private
114
-
115
- def configure_inspec_connection_options
116
- @inspec_options.merge! transport_connection_options
109
+ @inspec_options.merge! "color" => config_color
117
110
 
118
- @inspec_options
119
- .store(
120
- "connection_timeout",
121
- @inspec_options.delete("timeout")
122
- )
111
+ self
123
112
  end
124
113
 
125
- def configure_inspec_miscellaneous_options
126
- @inspec_options.merge!(
127
- "color" => config_color,
128
- "distinct_exit" => false,
129
- "sudo" => false,
130
- "sudo_command" => "sudo -E",
131
- "sudo_options" => "",
132
- )
133
- end
114
+ private
134
115
 
135
116
  def load_outputs
136
117
  instance.driver.retrieve_outputs do |outputs:|
@@ -140,12 +121,8 @@ module Kitchen
140
121
 
141
122
  def initialize(configuration = {})
142
123
  init_config configuration
143
- @inspec_options = {}
124
+ @inspec_options = { "distinct_exit" => false }
144
125
  @outputs = {}
145
- @transport_attributes = [
146
- :compression, :compression_level, :connection_retries, :connection_retry_sleep, :connection_timeout,
147
- :keepalive, :keepalive_interval, :max_wait_until_ready,
148
- ]
149
126
  end
150
127
 
151
128
  def inspec_profile_path
@@ -176,16 +153,6 @@ module Kitchen
176
153
  ::Kitchen::Terraform::InSpecOptionsMapper.new(system: system).map options: @inspec_options.dup
177
154
  end
178
155
 
179
- def transport_connection_options
180
- ::Kitchen::Util.stringified_hash(
181
- instance.transport.diagnose.select do |key|
182
- @transport_attributes.include? key
183
- end.tap do |options|
184
- options.store :timeout, options.fetch(:connection_timeout)
185
- end
186
- )
187
- end
188
-
189
156
  def verify(system:)
190
157
  ::Kitchen::Terraform::System
191
158
  .new(mapping: system)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Lane
@@ -61,22 +61,8 @@ cert_chain:
61
61
  XAjP/LERlXAwM+NCUycJw7BZMn7L2wIdnq6Le1rL6VJS17CZt2heuRtsF+3g0egR
62
62
  x97GmUumeM67PGeVodlIV65tdXrdlqKlHcE=
63
63
  -----END CERTIFICATE-----
64
- date: 2019-01-21 00:00:00.000000000 Z
64
+ date: 2019-04-06 00:00:00.000000000 Z
65
65
  dependencies:
66
- - !ruby/object:Gem::Dependency
67
- name: guard
68
- requirement: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '2.14'
73
- type: :development
74
- prerelease: false
75
- version_requirements: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '2.14'
80
66
  - !ruby/object:Gem::Dependency
81
67
  name: guard-bundler
82
68
  requirement: !ruby/object:Gem::Requirement
@@ -120,19 +106,19 @@ dependencies:
120
106
  - !ruby/object:Gem::Version
121
107
  version: '2.2'
122
108
  - !ruby/object:Gem::Dependency
123
- name: middleman
109
+ name: guard
124
110
  requirement: !ruby/object:Gem::Requirement
125
111
  requirements:
126
112
  - - "~>"
127
113
  - !ruby/object:Gem::Version
128
- version: '4.2'
114
+ version: '2.14'
129
115
  type: :development
130
116
  prerelease: false
131
117
  version_requirements: !ruby/object:Gem::Requirement
132
118
  requirements:
133
119
  - - "~>"
134
120
  - !ruby/object:Gem::Version
135
- version: '4.2'
121
+ version: '2.14'
136
122
  - !ruby/object:Gem::Dependency
137
123
  name: middleman-autoprefixer
138
124
  requirement: !ruby/object:Gem::Requirement
@@ -190,33 +176,33 @@ dependencies:
190
176
  - !ruby/object:Gem::Version
191
177
  version: '3.0'
192
178
  - !ruby/object:Gem::Dependency
193
- name: mini_racer
179
+ name: middleman
194
180
  requirement: !ruby/object:Gem::Requirement
195
181
  requirements:
196
182
  - - "~>"
197
183
  - !ruby/object:Gem::Version
198
- version: 0.2.0
184
+ version: '4.2'
199
185
  type: :development
200
186
  prerelease: false
201
187
  version_requirements: !ruby/object:Gem::Requirement
202
188
  requirements:
203
189
  - - "~>"
204
190
  - !ruby/object:Gem::Version
205
- version: 0.2.0
191
+ version: '4.2'
206
192
  - !ruby/object:Gem::Dependency
207
- name: pry
193
+ name: mini_racer
208
194
  requirement: !ruby/object:Gem::Requirement
209
195
  requirements:
210
196
  - - "~>"
211
197
  - !ruby/object:Gem::Version
212
- version: '0.10'
198
+ version: 0.2.0
213
199
  type: :development
214
200
  prerelease: false
215
201
  version_requirements: !ruby/object:Gem::Requirement
216
202
  requirements:
217
203
  - - "~>"
218
204
  - !ruby/object:Gem::Version
219
- version: '0.10'
205
+ version: 0.2.0
220
206
  - !ruby/object:Gem::Dependency
221
207
  name: pry-coolline
222
208
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +217,20 @@ dependencies:
231
217
  - - "~>"
232
218
  - !ruby/object:Gem::Version
233
219
  version: '0.2'
220
+ - !ruby/object:Gem::Dependency
221
+ name: pry
222
+ requirement: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - "~>"
225
+ - !ruby/object:Gem::Version
226
+ version: '0.10'
227
+ type: :development
228
+ prerelease: false
229
+ version_requirements: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - "~>"
232
+ - !ruby/object:Gem::Version
233
+ version: '0.10'
234
234
  - !ruby/object:Gem::Dependency
235
235
  name: rspec
236
236
  requirement: !ruby/object:Gem::Requirement
@@ -293,56 +293,70 @@ dependencies:
293
293
  requirements:
294
294
  - - "~>"
295
295
  - !ruby/object:Gem::Version
296
- version: '0.9'
296
+ version: 0.14.0
297
297
  type: :runtime
298
298
  prerelease: false
299
299
  version_requirements: !ruby/object:Gem::Requirement
300
300
  requirements:
301
301
  - - "~>"
302
302
  - !ruby/object:Gem::Version
303
- version: '0.9'
303
+ version: 0.14.0
304
304
  - !ruby/object:Gem::Dependency
305
305
  name: dry-validation
306
+ requirement: !ruby/object:Gem::Requirement
307
+ requirements:
308
+ - - '='
309
+ - !ruby/object:Gem::Version
310
+ version: 0.13.0
311
+ type: :runtime
312
+ prerelease: false
313
+ version_requirements: !ruby/object:Gem::Requirement
314
+ requirements:
315
+ - - '='
316
+ - !ruby/object:Gem::Version
317
+ version: 0.13.0
318
+ - !ruby/object:Gem::Dependency
319
+ name: inspec
306
320
  requirement: !ruby/object:Gem::Requirement
307
321
  requirements:
308
322
  - - "~>"
309
323
  - !ruby/object:Gem::Version
310
- version: '0.10'
324
+ version: '3.0'
311
325
  type: :runtime
312
326
  prerelease: false
313
327
  version_requirements: !ruby/object:Gem::Requirement
314
328
  requirements:
315
329
  - - "~>"
316
330
  - !ruby/object:Gem::Version
317
- version: '0.10'
331
+ version: '3.0'
318
332
  - !ruby/object:Gem::Dependency
319
- name: mixlib-shellout
333
+ name: json
320
334
  requirement: !ruby/object:Gem::Requirement
321
335
  requirements:
322
336
  - - "~>"
323
337
  - !ruby/object:Gem::Version
324
- version: '2.2'
338
+ version: 2.1.0
325
339
  type: :runtime
326
340
  prerelease: false
327
341
  version_requirements: !ruby/object:Gem::Requirement
328
342
  requirements:
329
343
  - - "~>"
330
344
  - !ruby/object:Gem::Version
331
- version: '2.2'
345
+ version: 2.1.0
332
346
  - !ruby/object:Gem::Dependency
333
- name: inspec
347
+ name: mixlib-shellout
334
348
  requirement: !ruby/object:Gem::Requirement
335
349
  requirements:
336
350
  - - "~>"
337
351
  - !ruby/object:Gem::Version
338
- version: '3.0'
352
+ version: '2.2'
339
353
  type: :runtime
340
354
  prerelease: false
341
355
  version_requirements: !ruby/object:Gem::Requirement
342
356
  requirements:
343
357
  - - "~>"
344
358
  - !ruby/object:Gem::Version
345
- version: '3.0'
359
+ version: '2.2'
346
360
  - !ruby/object:Gem::Dependency
347
361
  name: test-kitchen
348
362
  requirement: !ruby/object:Gem::Requirement
@@ -389,6 +403,7 @@ files:
389
403
  - lib/kitchen/terraform/command/version.rb
390
404
  - lib/kitchen/terraform/config_attribute.rb
391
405
  - lib/kitchen/terraform/config_attribute/backend_configurations.rb
406
+ - lib/kitchen/terraform/config_attribute/client.rb
392
407
  - lib/kitchen/terraform/config_attribute/color.rb
393
408
  - lib/kitchen/terraform/config_attribute/command_timeout.rb
394
409
  - lib/kitchen/terraform/config_attribute/lock.rb
@@ -452,7 +467,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
452
467
  version: '0'
453
468
  requirements:
454
469
  - Terraform >= 0.11.4, < 0.12.0
455
- rubygems_version: 3.0.2
470
+ rubygems_version: 3.0.3
456
471
  signing_key:
457
472
  specification_version: 4
458
473
  summary: Test Kitchen plugins for testing Terraform configuration
metadata.gz.sig CHANGED
Binary file