Module: Kitchen::Driver

Defined in:
lib/kitchen/driver.rb,
lib/kitchen/driver/base.rb,
lib/kitchen/driver/dummy.rb,
lib/kitchen/driver/proxy.rb,
lib/kitchen/driver/ssh_base.rb

Overview

A driver is responsible for carrying out the lifecycle activities of an instance, such as creating, converging, and destroying an instance.

Author:

Defined Under Namespace

Classes: Base, Dummy, Proxy, SSHBase

Constant Summary collapse

DEFAULT_PLUGIN =

Default driver plugin to use

"dummy".freeze

Class Method Summary collapse

Class Method Details

.for_plugin(plugin, config) ⇒ Driver::Base

Returns an instance of a driver given a plugin type string.

Parameters:

  • plugin (String)

    a driver plugin type, which will be constantized

  • config (Hash)

    a configuration hash to initialize the driver

Returns:

Raises:

  • (ClientError)

    if a driver instance could not be created

  • (UserError)

    if the driver's dependencies could not be met



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/kitchen/driver.rb', line 39

def self.for_plugin(plugin, config)
  first_load = require("kitchen/driver/#{plugin}")

  str_const = Thor::Util.camel_case(plugin)
  klass = self.const_get(str_const)
  object = klass.new(config)
  object.verify_dependencies if first_load
  object
rescue UserError
  raise
rescue LoadError, NameError
  raise ClientError,
    "Could not load the '#{plugin}' driver from the load path." +
      " Please ensure that your driver is installed as a gem or included" +
      " in your Gemfile if using Bundler."
end