kitchen-terraform 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kitchen-terraform might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3817060a934ee0a8712bcb0f68b4ba6662078276216384e26d01f74f5fe2608
4
- data.tar.gz: e477a746be09e08cc3c611c9fe679e4d2ccc620e216021755c14940f65834b06
3
+ metadata.gz: '06987257a4c260d1b96418960d13dfa4098745d75e175da00abd74b9e79578a2'
4
+ data.tar.gz: b160ce915cde5c453b646e7afa0bf5f74c9b62dc134cedd4ce275e1078359cfa
5
5
  SHA512:
6
- metadata.gz: 0557d8153736088165d4f9d14b0ebcc9b36a703fc1f31eaf2ef4e8aa3895e70e71652157c856a5cad4911ef3e99d96976ed44ac4fa7ec38e2d880714f6121254
7
- data.tar.gz: 266fa709671ce5c8f04ad92bcd498788459ed0aaefc7fd1de598c9c79f8df640e094b0434c380a3d71ac59aa6f71acb3eb582445fa0412c91c601045c89cab05
6
+ metadata.gz: 2f8fdd9a82a62c2e97d78935b95caee26f51a0e1df52acf511d1354bace0a740c1605fad44fdb7b5a089c7796b973236db980194505662ca2862dc8edbb08690
7
+ data.tar.gz: 03f6b585277114646e9fffc00e3ee4c562d3f3a8c0ba9185a601d213097114740ab3f4fc1ad7c9c1fe8dc373e4f7152bbb38cd8cf444517b5e5f0c556f999d32
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -6,16 +6,16 @@
6
6
  [![Gem downloads version][gem-downloads-version-shield]][kitchen-terraform-gem]
7
7
  [![Gem downloads total][gem-downloads-total-shield]][kitchen-terraform-gem]
8
8
 
9
- [![Test workflow][test-workflow-shield]][test-workflow]
9
+ [![Delivery][delivery-shield]][delivery-workflow]
10
+ [![Pages Build and Deployment][pages-build-deployment-shield]][pages-build-deployment-workflow]
10
11
  [![Code coverage][code-coverage-shield]][code-coverage]
11
12
  [![Maintainability][maintainability-shield]][maintainability]
12
13
  [![Technical debt][technical-debt-shield]][technical-debt]
13
- [![Dependencies][hakiri-shield]][hakiri]
14
14
 
15
15
  [![Gitter chat][gitter-shield]][gitter]
16
16
 
17
- Kitchen-Terraform provides a set of [Kitchen][kitchen] plugins
18
- which enable the use of Kitchen to converge a [Terraform][terraform]
17
+ Kitchen-Terraform provides a set of [Test Kitchen][test-kitchen] plugins
18
+ which enable the use of Test Kitchen to converge a [Terraform][terraform]
19
19
  configuration and verify the resulting infrastructure systems with
20
20
  [InSpec][inspec] controls.
21
21
 
@@ -35,7 +35,7 @@ Installation instructions can be found in the
35
35
  [Terraform: Install Terraform][terraform-install] article.
36
36
 
37
37
  Kitchen-Terraform supports versions of Terraform in the interval of
38
- `>= 0.11.4, < 1.1.0`.
38
+ `>= 0.11.4, < 2.0.0`.
39
39
 
40
40
  [tfenv] can be used to manage versions of Terraform on the system.
41
41
 
@@ -72,20 +72,28 @@ the semantic versioning of the Ruby gem.
72
72
 
73
73
  > Defining Kitchen-Terraform as a dependency for Bundler in a Gemfile
74
74
 
75
+ ---
76
+
75
77
  ```ruby
76
78
  source "https://rubygems.org/" do
77
- gem "kitchen-terraform", "~> 5.7"
79
+ gem "kitchen-terraform", "~> 7.0"
78
80
  end
79
81
  ```
80
82
 
83
+ ---
84
+
81
85
  Second, run the following command.
82
86
 
83
87
  > Installing Kitchen-Terraform with Bundler
84
88
 
89
+ ---
90
+
85
91
  ```sh
86
92
  bundle install
87
93
  ```
88
94
 
95
+ ---
96
+
89
97
  The preceding command will create a `Gemfile.lock` comprising a list
90
98
  of the resolved Ruby gem dependencies.
91
99
 
@@ -100,10 +108,14 @@ example.
100
108
 
101
109
  > Installing Kitchen-Terraform with RubyGems
102
110
 
111
+ ---
112
+
103
113
  ```sh
104
- gem install kitchen-terraform --version 6.0.0
114
+ gem install kitchen-terraform --version 7.0.0
105
115
  ```
106
116
 
117
+ ---
118
+
107
119
  This approach is not recommended as it requires more effort to install
108
120
  the gem in a manner that is reproducible and free of dependency
109
121
  conflicts.
@@ -123,25 +135,34 @@ Ed25519-type SSH keys.
123
135
 
124
136
  ## Usage
125
137
 
138
+ A familiarity with [Test Kitchen][test-kitchen] workflows and commands is required to use Kitchen-Terraform.
139
+
126
140
  ### Configuration
127
141
 
128
- Kitchen-Terraform provides three Test Kitchen plugins which must be
142
+ Kitchen-Terraform provides four Test Kitchen plugins which must be
129
143
  configured in a
130
- [Kitchen configuration file][kitchen-configuration-file] in
144
+ [Test Kitchen configuration file][kitchen-configuration-file] in
131
145
  order to successfully test Terraform configuration.
132
146
 
133
- The [Terraform driver][terraform-driver] manages the state of the
134
- Terraform root module.
147
+ The [Terraform driver][terraform-driver] is the bridge between Test
148
+ Kitchen and Terraform. It manages the [state][terraform-state] of the
149
+ Terraform root module under test by shelling out and running Terraform commands.
135
150
 
136
- The [Terraform provisioner][terraform-provisioner] uses the Terraform
137
- driver to apply changes to the Terraform state.
151
+ The [Terraform provisioner][terraform-provisioner] applies changes to
152
+ the Terraform state based on the configuration of the root module.
138
153
 
139
- The [Terraform verifier][terraform-verifier] uses InSpec to verify the
140
- Terraform state.
154
+ The [Terraform transport][terraform-transport] is responsible for the
155
+ integration with the Terraform CLI.
156
+
157
+ The [Terraform verifier][terraform-verifier] utilizes InSpec to verify
158
+ the behaviour and state of resources in the Terraform state.
141
159
 
142
160
  More information can be found in the
143
161
  [Ruby gem documentation][ruby-gem-documentation].
144
162
 
163
+ The `kitchen doctor` command can be used to validate the system and the
164
+ configuration file.
165
+
145
166
  ### Caveats
146
167
 
147
168
  Versions of Terraform in the 0.11 series may cause `kitchen test` to
@@ -158,7 +179,7 @@ Several tutorials are available on the
158
179
 
159
180
  The integration tests for Kitchen-Terraform can also be viewed as
160
181
  examples of how it works. The
161
- [integration test Kitchen configuration file][int-kitchen-config]
182
+ [integration test Test Kitchen configuration file][int-kitchen-config]
162
183
  and the [integration test directory][test-directory] provide several
163
184
  functional examples which exercise various features of
164
185
  Kitchen-Terraform.
@@ -225,9 +246,6 @@ Kitchen-Terraform is distributed under the [Apache License][license].
225
246
 
226
247
  <!-- Markdown links and image definitions -->
227
248
 
228
- [appveyor-build-status-shield]: https://ci.appveyor.com/api/projects/status/8d7t014gij5grk5r/branch/master?svg=true
229
- [appveyor-build-status]: https://ci.appveyor.com/project/aaron-lane/kitchen-terraform/branch/master
230
- [bundler-getting-started]: https://bundler.io/#getting-started
231
249
  [bundler-in-depth]: https://bundler.io/gemfile.html
232
250
  [bundler]: https://bundler.io/index.html#getting-started
233
251
  [changelog]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/CHANGELOG.md
@@ -235,20 +253,19 @@ Kitchen-Terraform is distributed under the [Apache License][license].
235
253
  [code-coverage]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
236
254
  [contributing-document]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/CONTRIBUTING.md
237
255
  [contributors]: https://github.com/newcontext-oss/kitchen-terraform/graphs/contributors
238
- [docker]: https://www.docker.com/
239
- [docker-community-edition]: https://store.docker.com/editions/community/docker-ce-server-ubuntu
240
- [docker-provider]: https://www.terraform.io/docs/providers/docker/index.html
256
+ [copado-github]: https://github.com/CopadoSolutions
257
+ [copado-linkedin]: https://www.linkedin.com/company/copado-solutions-s.l
258
+ [copado-twitter]: https://twitter.com/CopadoSolutions
259
+ [copado]: https://copado.com/
260
+ [delivery-shield]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/delivery.yml/badge.svg
261
+ [delivery-workflow]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/delivery.yml
241
262
  [gem-downloads-total-shield]: https://img.shields.io/gem/dt/kitchen-terraform.svg
242
263
  [gem-downloads-version-shield]: https://img.shields.io/gem/dtv/kitchen-terraform.svg
243
264
  [gem-version-shield]: https://img.shields.io/gem/v/kitchen-terraform.svg
244
265
  [gitter-shield]: https://img.shields.io/gitter/room/kitchen-terraform/Lobby.svg
245
266
  [gitter]: https://gitter.im/kitchen-terraform/Lobby
246
- [hakiri-shield]: https://hakiri.io/github/newcontext-oss/kitchen-terraform/master.svg
247
- [hakiri]: https://hakiri.io/github/newcontext-oss/kitchen-terraform/
248
- [inspec]: https://www.inspec.io/
267
+ [inspec]: https://community.chef.io/tools/chef-inspec
249
268
  [int-kitchen-config]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/kitchen.yml
250
- [issue-271]: https://github.com/newcontext-oss/kitchen-terraform/issues/271
251
- [kitchen]: http://kitchen.ci/index.html
252
269
  [kitchen-configuration-file]: https://docs.chef.io/config_yml_kitchen.html
253
270
  [kitchen-terraform-gem]: https://rubygems.org/gems/kitchen-terraform
254
271
  [kitchen-terraform-logo]: https://raw.githubusercontent.com/newcontext-oss/kitchen-terraform/master/assets/logo.png
@@ -256,10 +273,8 @@ Kitchen-Terraform is distributed under the [Apache License][license].
256
273
  [license]: https://github.com/newcontext-oss/kitchen-terraform/blob/master/LICENSE
257
274
  [maintainability-shield]: https://img.shields.io/codeclimate/maintainability-percentage/newcontext-oss/kitchen-terraform.svg
258
275
  [maintainability]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
259
- [copado-github]: https://github.com/CopadoSolutions
260
- [copado-linkedin]: https://www.linkedin.com/company/copado-solutions-s.l
261
- [copado-twitter]: https://twitter.com/CopadoSolutions
262
- [copado]: https://copado.com/
276
+ [pages-build-deployment-shield]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/pages/pages-build-deployment/badge.svg
277
+ [pages-build-deployment-workflow]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/pages/pages-build-deployment
263
278
  [rbenv]: https://github.com/rbenv/rbenv
264
279
  [rbnacl-installation]: https://github.com/crypto-rb/rbnacl/tree/v4.0.2#installation
265
280
  [ruby-branches]: https://www.ruby-lang.org/en/downloads/branches/
@@ -270,15 +285,14 @@ Kitchen-Terraform is distributed under the [Apache License][license].
270
285
  [rubygems-installing-gems]: http://guides.rubygems.org/rubygems-basics/#rubygems-installing-gems
271
286
  [technical-debt-shield]: https://img.shields.io/codeclimate/tech-debt/newcontext-oss/kitchen-terraform.svg
272
287
  [technical-debt]: https://codeclimate.com/github/newcontext-oss/kitchen-terraform/
273
- [terraform-cli]: https://www.terraform.io/docs/commands/index.html
288
+ [terraform-cli]: https://developer.hashicorp.com/terraform/cli/commands
274
289
  [terraform-driver]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Driver/Terraform
275
290
  [terraform-install]: https://www.terraform.io/intro/getting-started/install.html
276
291
  [terraform-provisioner]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Provisioner/Terraform
292
+ [terraform-state]: https://developer.hashicorp.com/terraform/language/state
293
+ [terraform-transport]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Transport/Terraform
277
294
  [terraform-verifier]: http://www.rubydoc.info/github/newcontext-oss/kitchen-terraform/Kitchen/Verifier/Terraform
278
295
  [terraform]: https://www.terraform.io/
279
296
  [test-directory]: https://github.com/newcontext-oss/kitchen-terraform/tree/master/test
280
- [test-workflow]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/tests.yml
281
- [test-workflow-shield]: https://github.com/newcontext-oss/kitchen-terraform/actions/workflows/tests.yml/badge.svg
297
+ [test-kitchen]: http://kitchen.ci/
282
298
  [tfenv]: https://github.com/kamatama41/tfenv
283
- [travis-build-status-shield]: https://img.shields.io/travis/com/newcontext-oss/kitchen-terraform.svg
284
- [travis-build-status]: https://travis-ci.com/newcontext-oss/kitchen-terraform
@@ -32,6 +32,7 @@ require "kitchen/terraform/configurable"
32
32
  require "kitchen/terraform/driver/create"
33
33
  require "kitchen/terraform/driver/destroy"
34
34
  require "kitchen/terraform/version_verifier"
35
+ require "kitchen/transport/terraform"
35
36
  require "rubygems"
36
37
  require "shellwords"
37
38
 
@@ -44,9 +45,9 @@ module Kitchen
44
45
  # @see http://www.rubydoc.info/gems/test-kitchen/Kitchen/Driver
45
46
  module Driver
46
47
 
47
- # The driver is the bridge between Test Kitchen and Terraform. It manages the
48
- # {https://www.terraform.io/docs/state/index.html state} of the Terraform root module by shelling out and running
49
- # Terraform commands.
48
+ # The Terraform driver is the bridge between Test Kitchen and Terraform. It manages the
49
+ # {https://developer.hashicorp.com/terraform/language/state state} of the Terraform root module under test by
50
+ # shelling out and running Terraform commands.
50
51
  #
51
52
  # === Commands
52
53
  #
@@ -76,6 +77,8 @@ module Kitchen
76
77
  #
77
78
  # ==== client
78
79
  #
80
+ # driver.client is deprecated; use transport.client instead.
81
+ #
79
82
  # {include:Kitchen::Terraform::ConfigAttribute::Client}
80
83
  #
81
84
  # ==== color
@@ -84,6 +87,8 @@ module Kitchen
84
87
  #
85
88
  # ==== command_timeout
86
89
  #
90
+ # driver.command_timeout is deprecated; use transport.command_timeout instead.
91
+ #
87
92
  # {include:Kitchen::Terraform::ConfigAttribute::CommandTimeout}
88
93
  #
89
94
  # ==== lock
@@ -104,6 +109,8 @@ module Kitchen
104
109
  #
105
110
  # ==== root_module_directory
106
111
  #
112
+ # driver.root_module_directory is deprecated; use transport.root_module_directory instead.
113
+ #
107
114
  # {include:Kitchen::Terraform::ConfigAttribute::RootModuleDirectory}
108
115
  #
109
116
  # ==== variable_files
@@ -135,20 +142,15 @@ module Kitchen
135
142
  class Terraform < ::Kitchen::Driver::Base
136
143
  kitchen_driver_api_version 2
137
144
 
138
- no_parallel_for(
139
- :create,
140
- :converge,
141
- :setup,
142
- :destroy
143
- )
144
-
145
145
  include ::Kitchen::Terraform::ConfigAttribute::BackendConfigurations
146
146
 
147
147
  include ::Kitchen::Terraform::ConfigAttribute::Client
148
+ deprecate_config_for :client, "use transport.client instead"
148
149
 
149
150
  include ::Kitchen::Terraform::ConfigAttribute::Color
150
151
 
151
152
  include ::Kitchen::Terraform::ConfigAttribute::CommandTimeout
153
+ deprecate_config_for :command_timeout, "use transport.command_timeout instead"
152
154
 
153
155
  include ::Kitchen::Terraform::ConfigAttribute::Lock
154
156
 
@@ -159,6 +161,7 @@ module Kitchen
159
161
  include ::Kitchen::Terraform::ConfigAttribute::PluginDirectory
160
162
 
161
163
  include ::Kitchen::Terraform::ConfigAttribute::RootModuleDirectory
164
+ deprecate_config_for :root_module_directory, "use transport.root_module_directory instead"
162
165
 
163
166
  include ::Kitchen::Terraform::ConfigAttribute::VariableFiles
164
167
 
@@ -168,13 +171,21 @@ module Kitchen
168
171
 
169
172
  include ::Kitchen::Terraform::Configurable
170
173
 
174
+ attr_reader :transport
175
+
171
176
  # Creates a Test Kitchen instance by initializing the working directory and creating a test workspace.
172
177
  #
173
- # @param _state [Hash] the mutable instance and driver state.
178
+ # @param state [Hash] the mutable instance and driver state.
174
179
  # @raise [Kitchen::ActionFailed] if the result of the action is a failure.
175
180
  # @return [void]
176
- def create(_state)
177
- create_strategy.call
181
+ def create(state)
182
+ ::Kitchen::Terraform::Driver::Create.new(
183
+ config: config,
184
+ connection: transport.connection(state),
185
+ logger: logger,
186
+ version_requirement: version_requirement,
187
+ workspace_name: workspace_name,
188
+ ).call
178
189
  rescue => error
179
190
  action_failed.call message: error.message
180
191
  end
@@ -182,35 +193,63 @@ module Kitchen
182
193
  # Destroys a Test Kitchen instance by initializing the working directory, selecting the test workspace,
183
194
  # deleting the state, selecting the default workspace, and deleting the test workspace.
184
195
  #
185
- # @param _state [Hash] the mutable instance and driver state.
196
+ # @param state [Hash] the mutable instance and driver state.
186
197
  # @raise [Kitchen::ActionFailed] if the result of the action is a failure.
187
198
  # @return [void]
188
- def destroy(_state)
189
- destroy_strategy.call
199
+ def destroy(state)
200
+ ::Kitchen::Terraform::Driver::Destroy.new(
201
+ config: config,
202
+ connection: transport.connection(state.merge(environment: { "TF_WARN_OUTPUT_ERRORS" => "true" })),
203
+ logger: logger,
204
+ version_requirement: version_requirement,
205
+ workspace_name: workspace_name,
206
+ ).call
190
207
  rescue => error
191
208
  action_failed.call message: error.message
192
209
  end
193
210
 
211
+ # doctor checks the system and configuration for common errors.
212
+ #
213
+ # @param state [Hash] the mutable Kitchen instance state.
214
+ # @return [Boolean] +true+ if any errors are found; +false+ if no errors are found.
215
+ def doctor(state)
216
+ errors = false
217
+
218
+ deprecated_config.each_pair do |attribute, message|
219
+ errors = true
220
+ logger.warn "driver.#{attribute} is deprecated: #{message}"
221
+ end
222
+
223
+ methods.each do |method|
224
+ next if !method.match? /doctor_config_.*/
225
+
226
+ config_error = send method
227
+ errors = errors || config_error
228
+ end
229
+
230
+ transport_errors = transport.doctor state
231
+ verifier_errors = instance.verifier.doctor state
232
+
233
+ errors || transport_errors || verifier_errors
234
+ end
235
+
194
236
  # #finalize_config! invokes the super implementation and then initializes the strategies.
195
237
  #
196
238
  # @param instance [Kitchen::Instance] an associated instance.
197
239
  # @raise [Kitchen::ClientError] if the instance is nil.
198
240
  # @return [self]
199
- # @see Kitchen::Configurable#finalize_config!
200
241
  def finalize_config!(instance)
201
- super instance
202
- self.create_strategy = ::Kitchen::Terraform::Driver::Create.new(
203
- config: config,
204
- logger: logger,
205
- version_requirement: version_requirement,
206
- workspace_name: workspace_name,
207
- )
208
- self.destroy_strategy = ::Kitchen::Terraform::Driver::Destroy.new(
209
- config: config,
210
- logger: logger,
211
- version_requirement: version_requirement,
212
- workspace_name: workspace_name,
213
- )
242
+ super
243
+
244
+ self.deprecated_config ||= {}
245
+
246
+ transport = instance.transport
247
+
248
+ self.transport = if ::Kitchen::Transport::Terraform == transport.class
249
+ transport
250
+ else
251
+ ::Kitchen::Transport::Terraform.new(config).finalize_config! instance
252
+ end
214
253
 
215
254
  self
216
255
  end
@@ -226,7 +265,8 @@ module Kitchen
226
265
 
227
266
  private
228
267
 
229
- attr_accessor :action_failed, :create_strategy, :destroy_strategy
268
+ attr_accessor :action_failed, :deprecated_config
269
+ attr_writer :transport
230
270
  end
231
271
  end
232
272
  end
@@ -24,7 +24,7 @@ module Kitchen
24
24
  #
25
25
  # @see http://www.rubydoc.info/gems/test-kitchen/Kitchen/Provisioner
26
26
  module Provisioner
27
- # The provisioner applies changes to the Terraform state based on the configuration of the root module.
27
+ # The Terraform provisioner applies changes to the Terraform state based on the configuration of the root module.
28
28
  #
29
29
  # === Commands
30
30
  #
@@ -80,33 +80,20 @@ module Kitchen
80
80
  # @param state [Hash] the mutable instance and provisioner state.
81
81
  # @raise [Kitchen::ActionFailed] if the result of the action is a failure.
82
82
  def call(state)
83
- converge_strategy.call state: state
84
- rescue => error
85
- action_failed.call message: error.message
86
- end
83
+ driver = instance.driver
84
+ transport = driver.transport
87
85
 
88
- # #finalize_config! invokes the super implementation and then initializes the strategy.
89
- #
90
- # @param instance [Kitchen::Instance] an associated instance.
91
- # @raise [Kitchen::ClientError] if the instance is nil.
92
- # @return [self]
93
- # @see Kitchen::Configurable#finalize_config!
94
- def finalize_config!(instance)
95
- super instance
96
- self.action_failed = ::Kitchen::Terraform::Raise::ActionFailed.new logger: logger
97
- self.converge_strategy = ::Kitchen::Terraform::Provisioner::Converge.new(
98
- config: instance.driver.send(:config),
86
+ ::Kitchen::Terraform::Provisioner::Converge.new(
87
+ config: driver.send(:config),
88
+ connection: transport.connection({}),
89
+ debug_connection: transport.connection(logger: ::Kitchen::Terraform::DebugLogger.new(logger: logger)),
99
90
  logger: logger,
100
91
  version_requirement: version_requirement,
101
92
  workspace_name: workspace_name,
102
- )
103
-
104
- self
93
+ ).call state: state
94
+ rescue => error
95
+ ::Kitchen::Terraform::Raise::ActionFailed.new(logger: logger).call message: error.message
105
96
  end
106
-
107
- private
108
-
109
- attr_accessor :action_failed, :converge_strategy
110
97
  end
111
98
  end
112
99
  end
@@ -68,6 +68,24 @@ module Kitchen
68
68
  def config_client_default_value
69
69
  "terraform"
70
70
  end
71
+
72
+ # #doctor_config_client validates the client configuration.
73
+ #
74
+ # @return [Boolean] +true+ if any errors are found; +false+ if no errors are found.
75
+ def doctor_config_client
76
+ errors = false
77
+
78
+ if !::File.exist? config_client
79
+ errors = true
80
+ logger.error "client '#{config_client}' does not exist"
81
+ end
82
+ if !::File.executable? config_client
83
+ errors = true
84
+ logger.error "client '#{config_client}' is not executable"
85
+ end
86
+
87
+ errors
88
+ end
71
89
  end
72
90
  end
73
91
  end
@@ -579,6 +579,20 @@ module Kitchen
579
579
  end,
580
580
  schema: ::Kitchen::Terraform::ConfigAttributeContract::Systems.new,
581
581
  ).apply config_attribute: self
582
+
583
+ # #doctor_config_systems validates the systems configuration.
584
+ #
585
+ # @return [Boolean] +true+ if any errors are found; +false+ if no errors are found.
586
+ def doctor_config_systems
587
+ errors = false
588
+
589
+ if config_systems.empty?
590
+ errors = true
591
+ logger.error "systems is empty"
592
+ end
593
+
594
+ errors
595
+ end
582
596
  end
583
597
  end
584
598
  end
@@ -21,7 +21,7 @@ require "kitchen/terraform/config_attribute_contract/hash_of_symbols_and_strings
21
21
  module Kitchen
22
22
  module Terraform
23
23
  module ConfigAttributeType
24
- # This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module
24
+ # This modules applies the behaviour of a configuration attribute of type hash of symbols and strings to a module
25
25
  # which must be included by a plugin class.
26
26
  #
27
27
  # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
@@ -22,7 +22,7 @@ require "kitchen/terraform/config_attribute_type"
22
22
  module Kitchen
23
23
  module Terraform
24
24
  module ConfigAttributeType
25
- # This module applies the behaviour of a configuration attribute of type integer to a module which must be
25
+ # This module applies the behaviour of a configuration attribute of type integer to a module which must be
26
26
  # included by a plugin class.
27
27
  #
28
28
  # @see http://dry-rb.org/gems/dry-validation/basics/working-with-schemas/ DRY Validation Working With Schemas
@@ -39,10 +39,9 @@ module Kitchen
39
39
  # @param instance [Kitchen::Instance] an associated instance.
40
40
  # @raise [Kitchen::ClientError] if the instance is nil.
41
41
  # @return [self]
42
- # @see Kitchen::Configurable#finalize_config!
43
42
  def finalize_config!(instance)
44
43
  super instance
45
- self.version_requirement = ::Gem::Requirement.new ">= 0.11.4", "< 1.1.0"
44
+ self.version_requirement = ::Gem::Requirement.new ">= 0.11.4", "< 2.0.0"
46
45
  self.workspace_name = "kitchen-terraform-#{::Shellwords.escape instance.name}"
47
46
  end
48
47
 
@@ -15,11 +15,11 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require "kitchen"
18
+ require "kitchen/shell_out"
18
19
  require "kitchen/terraform/command/init_factory"
19
20
  require "kitchen/terraform/command/version"
20
21
  require "kitchen/terraform/command/workspace_new"
21
22
  require "kitchen/terraform/command/workspace_select"
22
- require "kitchen/terraform/command_executor"
23
23
  require "kitchen/terraform/verify_version"
24
24
  require "rubygems"
25
25
 
@@ -46,7 +46,7 @@ module Kitchen
46
46
  class Create
47
47
  # #call executes the action.
48
48
  #
49
- # @raise [Kitchen::TransientFailure] if a command fails.
49
+ # @raise [Kitchen::StandardError] if a command fails.
50
50
  # @return [self]
51
51
  def call
52
52
  read_client_version
@@ -60,23 +60,17 @@ module Kitchen
60
60
  # #initialize prepares a new instance of the class.
61
61
  #
62
62
  # @param config [Hash] the configuration of the driver.
63
+ # @param connection [Kitchen::Terraform::Transport::Connection] a Terraform connection.
63
64
  # @param logger [Kitchen::Logger] a logger for logging messages.
64
65
  # @param version_requirement [Gem::VersionRequirement] the required version of the Terraform client.
65
66
  # @param workspace_name [String] the name of the Terraform workspace to select or to create.
66
67
  # @option config [String] :client the pathname of the Terraform client.
67
68
  # @return [Kitchen::Terraform::Driver::Create]
68
- def initialize(config:, logger:, version_requirement:, workspace_name:)
69
+ def initialize(config:, connection:, logger:, version_requirement:, workspace_name:)
69
70
  self.complete_config = config.to_hash.merge upgrade_during_init: true, workspace_name: workspace_name
71
+ self.connection = connection
70
72
  self.client_version = ::Gem::Version.new "0.0.0"
71
- self.command_executor = ::Kitchen::Terraform::CommandExecutor.new(
72
- client: complete_config.fetch(:client),
73
- logger: logger,
74
- )
75
73
  self.logger = logger
76
- self.options = {
77
- cwd: complete_config.fetch(:root_module_directory),
78
- timeout: complete_config.fetch(:command_timeout),
79
- }
80
74
  self.workspace_name = workspace_name
81
75
  self.workspace_new = ::Kitchen::Terraform::Command::WorkspaceNew.new config: complete_config
82
76
  self.workspace_select = ::Kitchen::Terraform::Command::WorkspaceSelect.new config: complete_config
@@ -92,10 +86,9 @@ module Kitchen
92
86
 
93
87
  attr_accessor(
94
88
  :client_version,
95
- :command_executor,
96
89
  :complete_config,
90
+ :connection,
97
91
  :logger,
98
- :options,
99
92
  :verify_version,
100
93
  :version,
101
94
  :workspace_name,
@@ -105,36 +98,28 @@ module Kitchen
105
98
 
106
99
  def create_or_select_workspace
107
100
  logger.warn "Creating the #{workspace_name} Terraform workspace..."
108
- command_executor.run command: workspace_new, options: options do |standard_output|
109
- end
101
+ connection.execute workspace_new
110
102
  logger.warn "Finished creating the #{workspace_name} Terraform workspace."
111
- rescue ::Kitchen::TransientFailure
103
+ rescue ::Kitchen::ShellOut::ShellCommandFailed
112
104
  select_workspace
113
105
  end
114
106
 
115
107
  def initialize_directory
116
108
  logger.warn "Initializing the Terraform working directory..."
117
- command_executor.run(
118
- command: ::Kitchen::Terraform::Command::InitFactory.new(version: client_version)
119
- .build(config: complete_config),
120
- options: options,
121
- ) do |standard_output|
122
- end
109
+ connection.execute ::Kitchen::Terraform::Command::InitFactory
110
+ .new(version: client_version).build(config: complete_config)
123
111
  logger.warn "Finished initializing the Terraform working directory."
124
112
  end
125
113
 
126
114
  def read_client_version
127
115
  logger.warn "Reading the Terraform client version..."
128
- command_executor.run command: version, options: options do |standard_output|
129
- self.client_version = ::Gem::Version.new standard_output.slice /Terraform v(\d+\.\d+\.\d+)/, 1
130
- end
116
+ self.client_version = ::Gem::Version.new connection.execute(version).slice /Terraform v(\d+\.\d+\.\d+)/, 1
131
117
  logger.warn "Finished reading the Terraform client version."
132
118
  end
133
119
 
134
120
  def select_workspace
135
121
  logger.warn "Selecting the #{workspace_name} Terraform workspace..."
136
- command_executor.run command: workspace_select, options: options do |standard_output|
137
- end
122
+ connection.execute workspace_select
138
123
  logger.warn "Finished selecting the #{workspace_name} Terraform workspace."
139
124
  end
140
125
  end