test-kitchen 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/ECOSYSTEM.md +6 -5
  4. data/lib/kitchen/cli.rb +24 -53
  5. data/lib/kitchen/command/doctor.rb +40 -0
  6. data/lib/kitchen/config.rb +6 -0
  7. data/lib/kitchen/configurable.rb +1 -1
  8. data/lib/kitchen/data_munger.rb +2 -0
  9. data/lib/kitchen/driver/base.rb +26 -1
  10. data/lib/kitchen/driver/dummy.rb +1 -0
  11. data/lib/kitchen/driver/exec.rb +71 -0
  12. data/lib/kitchen/driver/proxy.rb +2 -1
  13. data/lib/kitchen/instance.rb +13 -4
  14. data/lib/kitchen/provisioner/base.rb +8 -0
  15. data/lib/kitchen/provisioner/chef_base.rb +3 -1
  16. data/lib/kitchen/provisioner/shell.rb +21 -23
  17. data/lib/kitchen/transport/base.rb +8 -0
  18. data/lib/kitchen/transport/exec.rb +59 -0
  19. data/lib/kitchen/verifier/base.rb +8 -0
  20. data/lib/kitchen/version.rb +1 -1
  21. data/spec/kitchen/config_spec.rb +13 -0
  22. data/spec/kitchen/driver/base_spec.rb +18 -0
  23. data/spec/kitchen/driver/exec_spec.rb +75 -0
  24. data/spec/kitchen/provisioner/chef_base_spec.rb +9 -0
  25. data/spec/kitchen/provisioner/chef_solo_spec.rb +1 -1
  26. data/spec/kitchen/provisioner/chef_zero_spec.rb +1 -1
  27. data/spec/kitchen/provisioner/shell_spec.rb +22 -20
  28. data/spec/kitchen/ssh_spec.rb +0 -29
  29. data/spec/kitchen/transport/exec_spec.rb +79 -0
  30. data/spec/kitchen/transport/ssh_spec.rb +0 -29
  31. data/spec/spec_helper.rb +26 -0
  32. data/support/busser_install_command.sh +10 -3
  33. metadata +9 -8
  34. data/features/kitchen_driver_create_command.feature +0 -64
  35. data/features/kitchen_driver_discover_command.feature +0 -25
  36. data/lib/kitchen/command/driver_discover.rb +0 -102
  37. data/lib/kitchen/generator/driver_create.rb +0 -174
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97e193b25afda7ff71ca265f2b333536dbc66d8f
4
- data.tar.gz: f2a5f618364bba733e19fcf833e9966bb8a3a7fa
3
+ metadata.gz: e20828b8c1e7e6d38e56fd780945e80c1e2448c0
4
+ data.tar.gz: 991344adaf49eb62704258bcf3caa65f0b0b3920
5
5
  SHA512:
6
- metadata.gz: e961821cc1bd26c47f069ff8aef06e00d989addf6b0a0150851a8c367d198d0ae49a1edf13a7027f8d37f450ccb2a12d425cc834649088e78b6b579fdc8a6a80
7
- data.tar.gz: afcd17fd1f4956c925af332072cc449b17201875ffc892454b9f53cc24dd3692fea38e926699f6748bd4cde9658292f3723bb992781b7647002033a5d7f9b795
6
+ metadata.gz: 82d95c4a38fbb60cfc50e4dd8cf52e4e767a95d33b059aa223f4cc54b5bd089e9b1dd914b1e5342c59a2f5c361b34007911df2877093a11128374e1cc0e5f488
7
+ data.tar.gz: 44c4ed0d15ec894e1c9ebc2393710e11d6760083cfc3d76a4c29ce5f2dc5180601af4d889cace89fbd69abc8ebd5d92afb0980236a39904f9ee87e4405ce77e8
@@ -1,5 +1,64 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.19.0](https://github.com/test-kitchen/test-kitchen/tree/v1.19.0) (2017-11-1)
4
+ [Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.17.0...v1.19.0)
5
+
6
+ **Release Notes:**
7
+
8
+ #### Driver Commands Removed
9
+
10
+ The `kitchen driver` family of commands have been removed. It was not recommended
11
+ to use them and it was judged to be more harm than good to leave them in. If you
12
+ regularly create new drivers and relied on the skeleton generator, check out
13
+ other code skeleton projects like [`chef generate`](https://blog.chef.io/2014/12/09/guest-post-creating-your-own-chef-cookbook-generator/),
14
+ and [Cookiecutter](https://github.com/audreyr/cookiecutter).
15
+
16
+ #### `kitchen converge -D`
17
+
18
+ When you want to get debug logging for your provisioner or verifier, you can now
19
+ use the new `-D` (or `--debug`) command line option for `kitchen converge`,
20
+ `kitchen verify`, and `kitchen test`. Support has been added to the Chef provisioners,
21
+ avoiding the need to use the `log_level: debug` configuration option every time.
22
+
23
+ #### `exec` Driver
24
+
25
+ A new driver named `exec` is included with Test Kitchen which runs all the
26
+ provisioning and verification commands locally, rather than on a VM. This can
27
+ be used for testing on systems where you've already created the VM yourself and
28
+ installed Test Kitchen on it. Note that this is related but different from the
29
+ included `proxy` driver, which also connects to an existing server, but over
30
+ SSH/WinRM rather than running commands locally.
31
+
32
+ #### `shell` Provisioner `command`
33
+
34
+ Previously the included `shell` provisioner allowed running a user-specified bootstrap
35
+ script. This has been extended to allow specifying a `command` option with a
36
+ string to run, rather than managing a script file.
37
+
38
+ #### Faster Busser
39
+
40
+ The `busser` verifier has been improved to be faster on the second (or beyond)
41
+ verification, or in other cases where the required gems are already present.
42
+
43
+ #### `kitchen doctor`
44
+
45
+ A `kitchen doctor` command has been added, modeled on Homebrew's `brew doctor`.
46
+ This currently doesn't do much, but if you are a Kitchen plugin author, consider
47
+ adding more detailed debugging checks and troubleshooting help to your plugin
48
+ via this system.
49
+
50
+ **Merged pull requests**
51
+
52
+ - Basic framework for kitchen doctor [\#1301](https://github.com/test-kitchen/test-kitchen/pull/1301) ([coderanger](https://github.com/coderanger))
53
+ - add kitchen-sparkleformation driver to ECOSYSTEM.md [\#1300](https://github.com/test-kitchen/test-kitchen/pull/1300) ([pesimon](https://github.com/pesimon))
54
+ - Add a --debug command line option [\#1296](https://github.com/test-kitchen/test-kitchen/pull/1296) ([coderanger](https://github.com/coderanger))
55
+ - Exec driver [\#1295](https://github.com/test-kitchen/test-kitchen/pull/1295) ([coderanger](https://github.com/coderanger))
56
+ - Misc cleanups [\#1294](https://github.com/test-kitchen/test-kitchen/pull/1294) ([coderanger](https://github.com/coderanger))
57
+ - Upgrades to the shell provisioner [\#1293](https://github.com/test-kitchen/test-kitchen/pull/1293) ([coderanger](https://github.com/coderanger))
58
+ - Remove the `driver create` and `driver discover` commands [\#1290](https://github.com/test-kitchen/test-kitchen/pull/1290) ([coderanger](https://github.com/coderanger))
59
+ - Adds pre_create_command for running arbitrary commands [\#1243](https://github.com/test-kitchen/test-kitchen/pull/1243) ([sean797](https://github.com/sean797))
60
+ - Added better routine to install Busser+Plugins [\#1083](https://github.com/test-kitchen/test-kitchen/pull/1083) ([yeoldegrove](https://github.com/yeoldegrove))
61
+
3
62
  ## [v1.18.0](https://github.com/test-kitchen/test-kitchen/tree/v1.18.0) (2017-09-28)
4
63
  [Full Changelog](https://github.com/test-kitchen/test-kitchen/compare/v1.17.0...v1.18.0)
5
64
 
@@ -40,13 +40,13 @@ The following are community driven plugins.
40
40
 
41
41
  [kitchen-qemu][qemu] | [kitchen-cfengine][cfengine] | [kitchen-cloudformation][cloudformation] | [kitchen-wpar][wpar] | [kitchen-powervc][powervc] | [kitchen-terraform][terraform]
42
42
  ---- | ---- | ---- | ---- | ---- | ----
43
- [![Status](https://travis-ci.org/esmil/kitchen-qemu.svg?branch=master)](https://travis-ci.org/esmil/kitchen-qemu)| [![Status](https://travis-ci.org/nmische/kitchen-cfengine.svg?branch=master)](https://travis-ci.org/nmische/kitchen-cfengine) | [![Status](https://travis-ci.org/neillturner/kitchen-cloudformation.svg?branch=master)](https://travis-ci.org/neillturner/kitchen-cloudformation) | [![Status](https://travis-ci.org/adejoux/kitchen-wpar.svg?branch=master)](https://travis-ci.org/adejoux/kitchen-wpar) | [![Status](https://travis-ci.org/chmod666org/kitchen-powervc.svg?branch=master)](https://travis-ci.org/chmod666org/kitchen-powervc) | [![Status](https://travis-ci.org/newcontext-oss/kitchen-terraform.svg?branch=master)](https://travis-ci.org/newcontext-oss/kitchen-terraform)
43
+ [![Status](https://travis-ci.org/esmil/kitchen-qemu.svg?branch=master)](https://travis-ci.org/esmil/kitchen-qemu)| [![Status](https://travis-ci.org/nmische/kitchen-cfengine.svg?branch=master)](https://travis-ci.org/nmische/kitchen-cfengine) | [![Status](https://travis-ci.org/neillturner/kitchen-cloudformation.svg?branch=master)](https://travis-ci.org/neillturner/kitchen-cloudformation) | [![Status](https://travis-ci.org/adejoux/kitchen-wpar.svg?branch=master)](https://travis-ci.org/adejoux/kitchen-wpar) | [![Status](https://travis-ci.org/chmod666org/kitchen-powervc.svg?branch=master)](https://travis-ci.org/chmod666org/kitchen-powervc) | [![Status](https://travis-ci.org/newcontext-oss/kitchen-terraform.svg?branch=master)](https://travis-ci.org/newcontext-oss/kitchen-terraform)
44
44
  [![Gem Version](https://badge.fury.io/rb/kitchen-qemu.svg)](http://badge.fury.io/rb/kitchen-qemu) | [![Gem Version](https://badge.fury.io/rb/kitchen-cfengine.svg)](http://badge.fury.io/rb/kitchen-cfengine) | [![Gem Version](https://badge.fury.io/rb/kitchen-cloudformation.svg)](http://badge.fury.io/rb/kitchen-cloudformation) | [![Gem Version](https://badge.fury.io/rb/kitchen-wpar.svg)](http://badge.fury.io/rb/kitchen-wpar) | [![Gem Version](https://badge.fury.io/rb/kitchen-powervc.svg)](http://badge.fury.io/rb/kitchen-powervc) | [![Gem Version](https://badge.fury.io/rb/kitchen-terraform.svg)](http://badge.fury.io/rb/kitchen-terraform)
45
45
 
46
- [kitchen-azurerm][azurerm] |
47
- ---- |
48
- [![Status](https://travis-ci.org/pendrica/kitchen-azurerm.svg?branch=master)](https://travis-ci.org/pendrica/kitchen-azurerm) |
49
- [![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) |
46
+ [kitchen-azurerm][azurerm] | [kitchen-sparkleformation][sparkleformation]
47
+ ---- | ----
48
+ [![Status](https://travis-ci.org/pendrica/kitchen-azurerm.svg?branch=master)](https://travis-ci.org/pendrica/kitchen-azurerm) | [![Status](https://travis-ci.org/devkid/kitchen-sparkleformation.svg?branch=master)](https://travis-ci.org/devkid/kitchen-sparkleformation)
49
+ [![Gem Version](https://badge.fury.io/rb/kitchen-azurerm.svg)](http://badge.fury.io/rb/kitchen-azurerm) | [![Gem Version](https://badge.fury.io/rb/kitchen-sparkleformation.svg)](http://badge.fury.io/rb/kitchen-sparkleformation)
50
50
 
51
51
 
52
52
  [chefpartners]: https://github.com/chef-partners/
@@ -82,6 +82,7 @@ The following are community driven plugins.
82
82
  [qemu]: https://github.com/esmil/kitchen-qemu
83
83
  [cfengine]: https://github.com/nmische/kitchen-cfengine
84
84
  [cloudformation]: https://github.com/neillturner/kitchen-cloudformation
85
+ [sparkleformation]: https://github.com/devkid/kitchen-sparkleformation
85
86
  [wpar]: https://github.com/adejoux/kitchen-wpar
86
87
  [powervc]: https://github.com/chmod666org/kitchen-powervc
87
88
  [appbundle-updater]: https://github.com/chef/kitchen-appbundle-updater
@@ -19,7 +19,6 @@
19
19
  require "thor"
20
20
 
21
21
  require "kitchen"
22
- require "kitchen/generator/driver_create"
23
22
  require "kitchen/generator/init"
24
23
 
25
24
  module Kitchen
@@ -180,6 +179,13 @@ module Kitchen
180
179
  [Future DEPRECATION, use --concurrency]
181
180
  Run a #{action} against all matching instances concurrently.
182
181
  DESC
182
+ if action == :converge || action == :verify
183
+ method_option :debug,
184
+ aliases: "-D",
185
+ type: :boolean,
186
+ default: false,
187
+ desc: "Run the #{action} with debugging enabled."
188
+ end
183
189
  test_base_path
184
190
  log_options
185
191
  define_method(action) do |*args|
@@ -226,6 +232,11 @@ module Kitchen
226
232
  type: :boolean,
227
233
  default: false,
228
234
  desc: "Invoke init command if .kitchen.yml is missing"
235
+ method_option :debug,
236
+ aliases: "-D",
237
+ type: :boolean,
238
+ default: false,
239
+ desc: "Run the converge and verify with debugging enabled."
229
240
  test_base_path
230
241
  log_options
231
242
  def test(*args)
@@ -248,6 +259,16 @@ module Kitchen
248
259
  perform("package", "package", args)
249
260
  end
250
261
 
262
+ desc "doctor INSTANCE|REGEXP", "Check for common system problems"
263
+ log_options
264
+ method_option :all,
265
+ aliases: "-a",
266
+ desc: "Check all instances"
267
+ def doctor(*args)
268
+ update_config!
269
+ perform("doctor", "doctor", args)
270
+ end
271
+
251
272
  desc "exec INSTANCE|REGEXP -c REMOTE_COMMAND",
252
273
  "Execute command on one or more instance"
253
274
  method_option :command,
@@ -285,58 +306,6 @@ module Kitchen
285
306
  D
286
307
  tasks["init"].options = Kitchen::Generator::Init.class_options
287
308
 
288
- # Thor class for kitchen driver commands.
289
- #
290
- # @author Fletcher Nichol <fnichol@nichol.ca>
291
- class Driver < Thor
292
- include PerformCommand
293
-
294
- register Kitchen::Generator::DriverCreate, "create",
295
- "create [NAME]", "Create a new Kitchen Driver gem project"
296
- long_desc <<-D, for: "create"
297
- Create will generate a project scaffold for a brand new Test Kitchen
298
- Driver RubyGem. For example:
299
-
300
- > kitchen driver create foobar
301
-
302
- will create a project scaffold for a RubyGem called `kitchen-foobar'.
303
- D
304
- tasks["create"].options = Kitchen::Generator::DriverCreate.class_options
305
-
306
- desc "discover", "Discover Test Kitchen drivers published on RubyGems"
307
- long_desc <<-D
308
- Discover will perform a search aginst the RubyGems service for any
309
- published gems of the form: "kitchen-*". Note that it it cannot be
310
- guarenteed that every result is a driver, but chances are good most
311
- relevant drivers will be returned.
312
- D
313
- method_option :chef_config_path,
314
- default: nil,
315
- desc: "Path to chef config file containing proxy configuration to use"
316
- def discover
317
- perform("discover", "driver_discover", args)
318
- end
319
-
320
- # @return [String] basename
321
- def self.basename
322
- super + " driver"
323
- end
324
- end
325
-
326
- register Kitchen::CLI::Driver, "driver",
327
- "driver", "Driver subcommands"
328
-
329
- no_tasks do
330
- def invoke_task(command, *args)
331
- if command.name == "help" && args.first.first == "driver"
332
- Kitchen::CLI::Driver.task_help(shell, args.first.last)
333
- else
334
- super
335
- end
336
- end
337
- alias_method :invoke_command, :invoke_task
338
- end
339
-
340
309
  private
341
310
 
342
311
  # Ensure the any failing commands exit non-zero.
@@ -369,6 +338,8 @@ module Kitchen
369
338
  @config.test_base_path = File.absolute_path(options[:test_base_path])
370
339
  end
371
340
 
341
+ @config.debug = options[:debug]
342
+
372
343
  # Now that we have required configs, lets create our file logger
373
344
  Kitchen.logger = Kitchen.default_file_logger(
374
345
  log_level,
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require "kitchen/command"
17
+
18
+ module Kitchen
19
+ module Command
20
+ # Check for common system or configuration problems.
21
+ #
22
+ class Doctor < Kitchen::Command::Base
23
+ # Invoke the command.
24
+ def call
25
+ results = parse_subcommand(args.first)
26
+ if results.empty?
27
+ error("No instances configured, cannot check configuration. Please check your .kitchen.yml and confirm it has platform and suites sections.")
28
+ exit(1)
29
+ end
30
+ # By default only doctor the first instance to avoid output spam.
31
+ results = [results.first] unless options[:all]
32
+ failed = results.any? do |instance|
33
+ debug "Doctor on #{instance.name}."
34
+ instance.doctor_action
35
+ end
36
+ exit(1) if failed
37
+ end
38
+ end
39
+ end
40
+ end
@@ -78,6 +78,10 @@ module Kitchen
78
78
  # @api private
79
79
  attr_accessor :colorize
80
80
 
81
+ # @return [Boolean] whether to enable debugging in the provisioner/verifier plugin or not
82
+ # @api private
83
+ attr_accessor :debug
84
+
81
85
  # Creates a new configuration, representing a particular testing
82
86
  # configuration for a project.
83
87
  #
@@ -104,6 +108,7 @@ module Kitchen
104
108
  @colorize = options.fetch(:colorize) { Kitchen.tty? }
105
109
  @log_root = options.fetch(:log_root) { default_log_root }
106
110
  @test_base_path = options.fetch(:test_base_path) { default_test_base_path }
111
+ @debug = options.fetch(:debug) { false }
107
112
  end
108
113
 
109
114
  # @return [Collection<Instance>] all instances, resulting from all
@@ -214,6 +219,7 @@ module Kitchen
214
219
  test_base_path: test_base_path,
215
220
  log_level: log_level,
216
221
  log_overwrite: log_overwrite,
222
+ debug: debug,
217
223
  }
218
224
  end
219
225
 
@@ -304,7 +304,7 @@ module Kitchen
304
304
  # @return [String] wrapped shell code
305
305
  # @api private
306
306
  def wrap_shell_code(code)
307
- return env_wrapped code if powershell_shell?
307
+ return env_wrapped(code) if powershell_shell?
308
308
  Util.wrap_command((env_wrapped code))
309
309
  end
310
310
 
@@ -80,6 +80,7 @@ module Kitchen
80
80
  merged_data_for(:provisioner, suite, platform).tap do |pdata|
81
81
  set_kitchen_config_at!(pdata, :kitchen_root)
82
82
  set_kitchen_config_at!(pdata, :test_base_path)
83
+ set_kitchen_config_at!(pdata, :debug)
83
84
  combine_arrays!(pdata, :run_list, :platform, :suite)
84
85
  end
85
86
  end
@@ -118,6 +119,7 @@ module Kitchen
118
119
  set_kitchen_config_at!(vdata, :kitchen_root)
119
120
  set_kitchen_config_at!(vdata, :test_base_path)
120
121
  set_kitchen_config_at!(vdata, :log_level)
122
+ set_kitchen_config_at!(vdata, :debug)
121
123
  end
122
124
  end
123
125
 
@@ -17,6 +17,7 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require "kitchen/lazy_hash"
20
+ require "kitchen/shell_out"
20
21
 
21
22
  module Kitchen
22
23
  module Driver
@@ -26,6 +27,9 @@ module Kitchen
26
27
  class Base
27
28
  include Configurable
28
29
  include Logging
30
+ include ShellOut
31
+
32
+ default_config :pre_create_command, nil
29
33
 
30
34
  # Creates a new Driver object using the provided configuration data
31
35
  # which will be merged with any default configuration.
@@ -40,6 +44,7 @@ module Kitchen
40
44
  # @param state [Hash] mutable instance and driver state
41
45
  # @raise [ActionFailed] if the action could not be completed
42
46
  def create(state) # rubocop:disable Lint/UnusedMethodArgument
47
+ pre_create_command
43
48
  end
44
49
 
45
50
  # Destroys an instance.
@@ -56,6 +61,14 @@ module Kitchen
56
61
  def package(state) # rubocop:disable Lint/UnusedMethodArgument
57
62
  end
58
63
 
64
+ # Check system and configuration for common errors.
65
+ #
66
+ # @param state [Hash] mutable instance and driver state
67
+ # @returns [Boolean] Return true if a problem is found.
68
+ def doctor(state)
69
+ false
70
+ end
71
+
59
72
  class << self
60
73
  # @return [Array<Symbol>] an array of action method names that cannot
61
74
  # be run concurrently and must be run in serial via a shared mutex
@@ -81,7 +94,7 @@ module Kitchen
81
94
  # @param methods [Array<Symbol>] one or more actions as symbols
82
95
  # @raise [ClientError] if any method is not a valid action method name
83
96
  def self.no_parallel_for(*methods)
84
- action_methods = [:create, :setup, :verify, :destroy]
97
+ action_methods = [:create, :setup, :converge, :verify, :destroy]
85
98
 
86
99
  Array(methods).each do |meth|
87
100
  next if action_methods.include?(meth)
@@ -125,6 +138,18 @@ module Kitchen
125
138
 
126
139
  private
127
140
 
141
+ # Run command if config[:pre_create_command] is set
142
+ def pre_create_command
143
+ if config[:pre_create_command]
144
+ begin
145
+ run_command(config[:pre_create_command])
146
+ rescue ShellCommandFailed => error
147
+ raise ActionFailed,
148
+ "pre_create_command '#{config[:pre_create_command]}' failed to execute #{error}"
149
+ end
150
+ end
151
+ end
152
+
128
153
  # Intercepts any bare #puts calls in subclasses and issues an INFO log
129
154
  # event instead.
130
155
  #
@@ -36,6 +36,7 @@ module Kitchen
36
36
 
37
37
  # (see Base#create)
38
38
  def create(state)
39
+ # Intentionally not calling `super` to avoid pre_create_command.
39
40
  state[:my_id] = "#{instance.name}-#{Time.now.to_i}"
40
41
  report(:create, state)
41
42
  end
@@ -0,0 +1,71 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ require "kitchen/driver/base"
17
+ require "kitchen/shell_out"
18
+ require "kitchen/transport/exec"
19
+ require "kitchen/version"
20
+
21
+ module Kitchen
22
+ module Driver
23
+ # Simple driver that runs commands locally. As with the proxy driver, this
24
+ # has no isolation in general.
25
+ class Exec < Kitchen::Driver::Base
26
+ include ShellOut
27
+
28
+ plugin_version Kitchen::VERSION
29
+
30
+ default_config :reset_command, nil
31
+
32
+ no_parallel_for :create, :converge, :destroy
33
+
34
+ # Hack to force using the exec transport when using this driver.
35
+ # If someone comes up with a use case for using the driver with a different
36
+ # transport, please let us know.
37
+ #
38
+ # @api private
39
+ def finalize_config!(instance)
40
+ super.tap do
41
+ instance.transport = Kitchen::Transport::Exec.new
42
+ end
43
+ end
44
+
45
+ # (see Base#create)
46
+ def create(state)
47
+ super
48
+ reset_instance(state)
49
+ end
50
+
51
+ # (see Base#destroy)
52
+ def destroy(state)
53
+ reset_instance(state)
54
+ end
55
+
56
+ private
57
+
58
+ # Resets the non-Kitchen managed instance using by issuing a command
59
+ # over SSH.
60
+ #
61
+ # @param state [Hash] the state hash
62
+ # @api private
63
+ def reset_instance(state)
64
+ if cmd = config[:reset_command]
65
+ info("Resetting instance state with command: #{cmd}")
66
+ run_command(cmd)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end