kitchen-terraform 5.6.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +19 -19
  5. data/lib/kitchen/driver/terraform.rb +1 -1
  6. data/lib/kitchen/provisioner/terraform.rb +1 -1
  7. data/lib/kitchen/terraform.rb +1 -1
  8. data/lib/kitchen/terraform/breaking.rb +1 -1
  9. data/lib/kitchen/terraform/command.rb +1 -1
  10. data/lib/kitchen/terraform/command/apply.rb +1 -1
  11. data/lib/kitchen/terraform/command/destroy.rb +1 -1
  12. data/lib/kitchen/terraform/command/get.rb +1 -1
  13. data/lib/kitchen/terraform/command/init.rb +3 -80
  14. data/lib/kitchen/terraform/command/init/post_zero_fifteen_zero.rb +89 -0
  15. data/lib/kitchen/terraform/command/init/pre_zero_fifteen_zero.rb +101 -0
  16. data/lib/kitchen/terraform/command/init_factory.rb +52 -0
  17. data/lib/kitchen/terraform/command/output.rb +1 -1
  18. data/lib/kitchen/terraform/command/validate.rb +3 -41
  19. data/lib/kitchen/terraform/command/validate/post_zero_fifteen_zero.rb +51 -0
  20. data/lib/kitchen/terraform/command/validate/pre_zero_fifteen_zero.rb +65 -0
  21. data/lib/kitchen/terraform/command/validate_factory.rb +54 -0
  22. data/lib/kitchen/terraform/command/version.rb +1 -1
  23. data/lib/kitchen/terraform/command/workspace_delete.rb +1 -1
  24. data/lib/kitchen/terraform/command/workspace_new.rb +1 -1
  25. data/lib/kitchen/terraform/command/workspace_select.rb +1 -1
  26. data/lib/kitchen/terraform/command_executor.rb +3 -5
  27. data/lib/kitchen/terraform/command_flag.rb +1 -1
  28. data/lib/kitchen/terraform/command_flag/backend_config.rb +1 -1
  29. data/lib/kitchen/terraform/command_flag/color.rb +1 -1
  30. data/lib/kitchen/terraform/command_flag/lock_timeout.rb +1 -1
  31. data/lib/kitchen/terraform/command_flag/plugin_dir.rb +1 -1
  32. data/lib/kitchen/terraform/command_flag/upgrade.rb +2 -2
  33. data/lib/kitchen/terraform/command_flag/var.rb +1 -1
  34. data/lib/kitchen/terraform/command_flag/var_file.rb +1 -1
  35. data/lib/kitchen/terraform/config_attribute.rb +1 -1
  36. data/lib/kitchen/terraform/config_attribute/backend_configurations.rb +1 -1
  37. data/lib/kitchen/terraform/config_attribute/client.rb +3 -3
  38. data/lib/kitchen/terraform/config_attribute/color.rb +3 -3
  39. data/lib/kitchen/terraform/config_attribute/command_timeout.rb +1 -1
  40. data/lib/kitchen/terraform/config_attribute/fail_fast.rb +3 -3
  41. data/lib/kitchen/terraform/config_attribute/lock.rb +3 -3
  42. data/lib/kitchen/terraform/config_attribute/lock_timeout.rb +1 -1
  43. data/lib/kitchen/terraform/config_attribute/parallelism.rb +1 -1
  44. data/lib/kitchen/terraform/config_attribute/plugin_directory.rb +3 -3
  45. data/lib/kitchen/terraform/config_attribute/root_module_directory.rb +3 -3
  46. data/lib/kitchen/terraform/config_attribute/systems.rb +552 -4
  47. data/lib/kitchen/terraform/config_attribute/variable_files.rb +3 -3
  48. data/lib/kitchen/terraform/config_attribute/variables.rb +1 -1
  49. data/lib/kitchen/terraform/config_attribute/verify_version.rb +3 -3
  50. data/lib/kitchen/terraform/config_attribute_cacher.rb +1 -1
  51. data/lib/kitchen/terraform/{config_predicates.rb → config_attribute_contract.rb} +3 -3
  52. data/lib/kitchen/terraform/config_attribute_contract/array_of_strings.rb +30 -0
  53. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/boolean.rb +7 -11
  54. data/lib/kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings.rb +41 -0
  55. data/lib/kitchen/terraform/{config_schemas.rb → config_attribute_contract/integer.rb} +10 -3
  56. data/lib/kitchen/terraform/config_attribute_contract/optional_string.rb +30 -0
  57. data/lib/kitchen/terraform/{config_schemas → config_attribute_contract}/string.rb +7 -9
  58. data/lib/kitchen/terraform/config_attribute_contract/systems.rb +63 -0
  59. data/lib/kitchen/terraform/config_attribute_definer.rb +2 -2
  60. data/lib/kitchen/terraform/config_attribute_type.rb +1 -1
  61. data/lib/kitchen/terraform/config_attribute_type/hash_of_symbols_and_strings.rb +9 -16
  62. data/lib/kitchen/terraform/config_attribute_type/integer.rb +27 -23
  63. data/lib/kitchen/terraform/configurable.rb +2 -2
  64. data/lib/kitchen/terraform/debug_logger.rb +1 -1
  65. data/lib/kitchen/terraform/deprecating.rb +1 -1
  66. data/lib/kitchen/terraform/driver.rb +1 -1
  67. data/lib/kitchen/terraform/driver/create.rb +39 -16
  68. data/lib/kitchen/terraform/driver/destroy.rb +53 -21
  69. data/lib/kitchen/terraform/error.rb +1 -1
  70. data/lib/kitchen/terraform/file_path_config_attribute_definer.rb +1 -1
  71. data/lib/kitchen/terraform/inspec.rb +1 -1
  72. data/lib/kitchen/terraform/inspec/fail_fast_with_hosts.rb +1 -1
  73. data/lib/kitchen/terraform/inspec/fail_slow_with_hosts.rb +1 -1
  74. data/lib/kitchen/terraform/inspec/without_hosts.rb +1 -1
  75. data/lib/kitchen/terraform/inspec_factory.rb +1 -1
  76. data/lib/kitchen/terraform/inspec_options_factory.rb +1 -1
  77. data/lib/kitchen/terraform/inspec_runner.rb +8 -1
  78. data/lib/kitchen/terraform/outputs_manager.rb +1 -1
  79. data/lib/kitchen/terraform/outputs_parser.rb +1 -1
  80. data/lib/kitchen/terraform/outputs_reader.rb +2 -2
  81. data/lib/kitchen/terraform/provisioner.rb +1 -1
  82. data/lib/kitchen/terraform/provisioner/converge.rb +52 -25
  83. data/lib/kitchen/terraform/raise.rb +1 -1
  84. data/lib/kitchen/terraform/raise/action_failed.rb +1 -1
  85. data/lib/kitchen/terraform/raise/client_error.rb +1 -1
  86. data/lib/kitchen/terraform/shell_out.rb +6 -5
  87. data/lib/kitchen/terraform/system.rb +1 -1
  88. data/lib/kitchen/terraform/system_attrs_inputs_resolver.rb +1 -1
  89. data/lib/kitchen/terraform/system_attrs_outputs_resolver.rb +1 -1
  90. data/lib/kitchen/terraform/system_bastion_host_resolver.rb +1 -1
  91. data/lib/kitchen/terraform/system_hosts_resolver.rb +1 -1
  92. data/lib/kitchen/terraform/system_inspec_map.rb +1 -1
  93. data/lib/kitchen/terraform/systems_verifier.rb +1 -1
  94. data/lib/kitchen/terraform/systems_verifier/fail_fast.rb +1 -1
  95. data/lib/kitchen/terraform/systems_verifier/fail_slow.rb +1 -1
  96. data/lib/kitchen/terraform/systems_verifier_factory.rb +1 -1
  97. data/lib/kitchen/terraform/unsupported_client_version_error.rb +1 -1
  98. data/lib/kitchen/terraform/variables_manager.rb +1 -1
  99. data/lib/kitchen/terraform/verify_version.rb +5 -17
  100. data/lib/kitchen/terraform/verify_version_rescue_strategy.rb +1 -1
  101. data/lib/kitchen/terraform/verify_version_rescue_strategy/permissive.rb +1 -1
  102. data/lib/kitchen/terraform/verify_version_rescue_strategy/strict.rb +1 -1
  103. data/lib/kitchen/terraform/verify_version_rescue_strategy_factory.rb +1 -1
  104. data/lib/kitchen/terraform/version.rb +2 -2
  105. data/lib/kitchen/terraform/version_verifier.rb +1 -1
  106. data/lib/kitchen/terraform/version_verifier_strategy.rb +1 -1
  107. data/lib/kitchen/terraform/version_verifier_strategy/supported.rb +1 -1
  108. data/lib/kitchen/terraform/version_verifier_strategy/unsupported.rb +1 -1
  109. data/lib/kitchen/terraform/version_verifier_strategy_factory.rb +1 -1
  110. data/lib/kitchen/verifier/terraform.rb +1 -1
  111. metadata +88 -53
  112. metadata.gz.sig +0 -0
  113. data/lib/kitchen/terraform/config_predicates/hash_of_symbols_and_strings.rb +0 -81
  114. data/lib/kitchen/terraform/config_schemas/array_of_strings.rb +0 -38
  115. data/lib/kitchen/terraform/config_schemas/optional_string.rb +0 -38
  116. data/lib/kitchen/terraform/config_schemas/system.rb +0 -609
  117. data/lib/kitchen/terraform/config_schemas/systems.rb +0 -37
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ module Kitchen
48
48
  attr_accessor :command_executor, :no_outputs_defined
49
49
 
50
50
  def run(command:, options:)
51
- command_executor.run command: command, options: options do |standard_output:|
51
+ command_executor.run command: command, options: options do |standard_output|
52
52
  yield json_outputs: standard_output
53
53
  end
54
54
  rescue ::Kitchen::TransientFailure => error
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ require "kitchen/terraform/command_executor"
19
19
  require "kitchen/terraform/command/apply"
20
20
  require "kitchen/terraform/command/get"
21
21
  require "kitchen/terraform/command/output"
22
- require "kitchen/terraform/command/validate"
22
+ require "kitchen/terraform/command/validate_factory"
23
23
  require "kitchen/terraform/command/workspace_select"
24
24
  require "kitchen/terraform/debug_logger"
25
25
  require "kitchen/terraform/outputs_manager"
@@ -28,6 +28,7 @@ require "kitchen/terraform/outputs_reader"
28
28
  require "kitchen/terraform/variables_manager"
29
29
  require "kitchen/terraform/verify_version"
30
30
  require "kitchen/terraform/version"
31
+ require "rubygems"
31
32
 
32
33
  module Kitchen
33
34
  module Terraform
@@ -44,7 +45,13 @@ module Kitchen
44
45
  #
45
46
  # ===== Validating the Terraform Root Module
46
47
  #
47
- # {include:Kitchen::Terraform::Command::Validate}
48
+ # ====== Terraform >= 0.15.0
49
+ #
50
+ # {include:Kitchen::Terraform::Command::Validate::PostZeroFifteenZero}
51
+ #
52
+ # ====== Terraform < 0.15.0
53
+ #
54
+ # {include:Kitchen::Terraform::Command::Validate::PreZeroFifteenZero}
48
55
  #
49
56
  # ===== Applying the Terraform State Changes
50
57
  #
@@ -60,7 +67,8 @@ module Kitchen
60
67
  # @raise [Kitchen::TransientFailure] if a command fails.
61
68
  # @return [self]
62
69
  def call(state:)
63
- verify_version.call command: version, options: options
70
+ read_client_version
71
+ verify_version.call version: client_version
64
72
  execute_workflow
65
73
  save_variables_and_outputs state: state
66
74
 
@@ -75,63 +83,62 @@ module Kitchen
75
83
  # @param workspace_name [String] the name of the Terraform workspace to select or to create.
76
84
  # @return [Kitchen::Terraform::Driver::Converge]
77
85
  def initialize(config:, logger:, version_requirement:, workspace_name:)
78
- client = config.fetch :client
79
- hash_config = config.to_hash.merge workspace_name: workspace_name
86
+ self.complete_config = config.to_hash.merge workspace_name: workspace_name
87
+ client = complete_config.fetch :client
88
+ self.client_version = ::Gem::Version.new "0.0.0"
80
89
  self.command_executor = ::Kitchen::Terraform::CommandExecutor.new(
81
90
  client: client,
82
91
  logger: logger,
83
92
  )
84
93
  self.logger = logger
85
- self.options = { cwd: config.fetch(:root_module_directory), timeout: config.fetch(:command_timeout) }
94
+ self.options = {
95
+ cwd: complete_config.fetch(:root_module_directory),
96
+ timeout: complete_config.fetch(:command_timeout),
97
+ }
86
98
  self.workspace_name = workspace_name
87
- self.apply = ::Kitchen::Terraform::Command::Apply.new config: config
88
- self.get = ::Kitchen::Terraform::Command::Get.new
89
- self.output = ::Kitchen::Terraform::Command::Output.new
99
+ initialize_commands
90
100
  initialize_outputs_handlers client: client, logger: logger
91
- self.validate = ::Kitchen::Terraform::Command::Validate.new config: config
92
- self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: hash_config
93
- self.variables = config.fetch :variables
101
+ self.variables = complete_config.fetch :variables
94
102
  self.variables_manager = ::Kitchen::Terraform::VariablesManager.new
95
103
  self.verify_version = ::Kitchen::Terraform::VerifyVersion.new(
96
- command_executor: command_executor,
97
- config: config,
104
+ config: complete_config,
98
105
  logger: logger,
99
106
  version_requirement: version_requirement,
100
107
  )
101
- self.version = ::Kitchen::Terraform::Command::Version.new
102
108
  end
103
109
 
104
110
  private
105
111
 
106
112
  attr_accessor(
107
- :command_executor,
108
113
  :apply,
114
+ :client_version,
115
+ :command_executor,
116
+ :complete_config,
109
117
  :get,
110
- :output,
111
- :validate,
112
- :workspace_select,
113
118
  :logger,
114
119
  :options,
120
+ :output,
115
121
  :outputs_manager,
116
122
  :outputs_parser,
117
123
  :outputs_reader,
118
- :variables,
119
124
  :variables_manager,
125
+ :variables,
120
126
  :verify_version,
121
127
  :version,
122
128
  :workspace_name,
129
+ :workspace_select,
123
130
  )
124
131
 
125
132
  def build_infrastructure
126
133
  logger.warn "Building the infrastructure based on the Terraform configuration..."
127
- command_executor.run command: apply, options: options do |standard_output:|
134
+ command_executor.run command: apply, options: options do |standard_output|
128
135
  end
129
136
  logger.warn "Finished building the infrastructure based on the Terraform configuration."
130
137
  end
131
138
 
132
139
  def download_modules
133
140
  logger.warn "Downloading the modules needed for the Terraform configuration..."
134
- command_executor.run command: get, options: options do |standard_output:|
141
+ command_executor.run command: get, options: options do |standard_output|
135
142
  end
136
143
  logger.warn "Finished downloading the modules needed for the Terraform configuration."
137
144
  end
@@ -143,6 +150,14 @@ module Kitchen
143
150
  build_infrastructure
144
151
  end
145
152
 
153
+ def initialize_commands
154
+ self.apply = ::Kitchen::Terraform::Command::Apply.new config: complete_config
155
+ self.get = ::Kitchen::Terraform::Command::Get.new
156
+ self.output = ::Kitchen::Terraform::Command::Output.new
157
+ self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: complete_config
158
+ self.version = ::Kitchen::Terraform::Command::Version.new
159
+ end
160
+
146
161
  def initialize_outputs_handlers(client:, logger:)
147
162
  self.outputs_manager = ::Kitchen::Terraform::OutputsManager.new
148
163
  self.outputs_parser = ::Kitchen::Terraform::OutputsParser.new
@@ -172,6 +187,14 @@ module Kitchen
172
187
  end
173
188
  end
174
189
 
190
+ def read_client_version
191
+ logger.warn "Reading the Terraform client version..."
192
+ command_executor.run command: version, options: options do |standard_output|
193
+ self.client_version = ::Gem::Version.new standard_output.slice /Terraform v(\d+\.\d+\.\d+)/, 1
194
+ end
195
+ logger.warn "Finished reading the Terraform client version."
196
+ end
197
+
175
198
  def save_outputs(parsed_outputs:, state:)
176
199
  logger.warn "Writing the output variables to the Kitchen instance state..."
177
200
  outputs_manager.save outputs: parsed_outputs, state: state
@@ -189,14 +212,18 @@ module Kitchen
189
212
 
190
213
  def select_workspace
191
214
  logger.warn "Selecting the #{workspace_name} Terraform workspace..."
192
- command_executor.run command: workspace_select, options: options do |standard_output:|
215
+ command_executor.run command: workspace_select, options: options do |standard_output|
193
216
  end
194
217
  logger.warn "Finished selecting the #{workspace_name} Terraform workspace."
195
218
  end
196
219
 
197
220
  def validate_files
198
221
  logger.warn "Validating the Terraform configuration files..."
199
- command_executor.run command: validate, options: options do |standard_output:|
222
+ command_executor.run(
223
+ command: ::Kitchen::Terraform::Command::ValidateFactory.new(version: client_version)
224
+ .build(config: complete_config),
225
+ options: options,
226
+ ) do |standard_output|
200
227
  end
201
228
  logger.warn "Finished validating the Terraform configuration files."
202
229
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -29,16 +29,17 @@ module Kitchen
29
29
  #
30
30
  # @param command [String] the command to run.
31
31
  # @param logger [Kitchen::Logger] a logger for logging messages.
32
+ # @param options [Hash] options which adjust the execution of the command.
32
33
  # @return [Kitchen::Terraform::CommandExecutor]
33
34
  def initialize(command:, logger:, options:)
34
35
  self.command = command
35
36
  self.logger = logger
36
37
  self.shell_out = ::Mixlib::ShellOut.new(
37
38
  command,
38
- options.merge(
39
- environment: { "LC_ALL" => nil, "TF_IN_AUTOMATION" => "true", "TF_WARN_OUTPUT_ERRORS" => "1" },
39
+ {
40
+ environment: { "LC_ALL" => nil, "TF_IN_AUTOMATION" => "true" },
40
41
  live_stream: logger,
41
- )
42
+ }.merge(options)
42
43
  )
43
44
  end
44
45
 
@@ -50,7 +51,7 @@ module Kitchen
50
51
  def run
51
52
  execute_workflow
52
53
 
53
- yield standard_output: shell_out.stdout
54
+ yield shell_out.stdout
54
55
 
55
56
  self
56
57
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -27,13 +27,12 @@ module Kitchen
27
27
  class VerifyVersion
28
28
  # #call invokes the verification.
29
29
  #
30
- # @param command [Kitchen::Terraform::Command::Version] the version command.
31
- # @param options [Hash] options for running the command.
30
+ # @param version [Gem::Version] the Terraform client version.
32
31
  # @raise [Kitchen::ActionFailed] if the verification fails.
33
32
  # @return [self]
34
- def call(command:, options:)
33
+ def call(version:)
35
34
  logger.warn start_message
36
- run_version_and_verify command: command, options: options
35
+ version_verifier.verify version: version
37
36
  logger.warn finish_message
38
37
  rescue ::Kitchen::Terraform::UnsupportedClientVersionError
39
38
  rescue_strategy.call
@@ -49,8 +48,7 @@ module Kitchen
49
48
  # @option config [Boolean] :verify_version a toggle of strict or permissive verification of support for the
50
49
  # version of the Terraform client.
51
50
  # @return [Kitchen::Terraform::VerifyVersion]
52
- def initialize(command_executor:, config:, logger:, version_requirement:)
53
- self.command_executor = command_executor
51
+ def initialize(config:, logger:, version_requirement:)
54
52
  self.finish_message = "Finished verifying the Terraform client version."
55
53
  self.logger = logger
56
54
  self.rescue_strategy = ::Kitchen::Terraform::VerifyVersionRescueStrategyFactory.new(
@@ -64,22 +62,12 @@ module Kitchen
64
62
  private
65
63
 
66
64
  attr_accessor(
67
- :command_executor,
68
65
  :finish_message,
69
66
  :logger,
70
- :options,
71
67
  :rescue_strategy,
72
68
  :start_message,
73
69
  :version_verifier
74
70
  )
75
-
76
- def run_version_and_verify(command:, options:)
77
- logger.warn "Reading the Terraform client version..."
78
- command_executor.run command: command, options: options do |standard_output:|
79
- logger.warn "Finished reading the Terraform client version."
80
- version_verifier.verify version: ::Gem::Version.new(standard_output.slice(/Terraform v(\d+\.\d+\.\d+)/, 1))
81
- end
82
- end
83
71
  end
84
72
  end
85
73
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2016-2019 New Context, Inc.
3
+ # Copyright 2016-2021 Copado NCS LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.