Class: Kitchen::Driver::Base

Inherits:
Object
  • Object
show all
Includes:
Configurable, Logging
Defined in:
lib/kitchen/driver/base.rb

Overview

Base class for a driver.

Direct Known Subclasses

Dummy

Class Attribute Summary collapse

Attributes included from Configurable

#instance

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Methods included from Configurable

#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?

Constructor Details

#initialize(config = {}) ⇒ Base

Creates a new Driver object using the provided configuration data which will be merged with any default configuration.



37
38
39
# File 'lib/kitchen/driver/base.rb', line 37

def initialize(config = {})
  init_config(config)
end

Class Attribute Details

.serial_actionsArray<Symbol> (readonly)



58
59
60
# File 'lib/kitchen/driver/base.rb', line 58

def serial_actions
  @serial_actions
end

Class Method Details

.kitchen_driver_api_version(version) ⇒ Object

Sets the API version for this driver. If the driver does not set this value, then nil will be used and reported.

Sets the API version for this driver

rubocop:disable Style/TrivialAccessors

Examples:

setting an API version


module Kitchen
  module Driver
    class NewDriver < Kitchen::Driver::Base

      kitchen_driver_api_version 2

    end
  end
end


112
113
114
# File 'lib/kitchen/driver/base.rb', line 112

def self.kitchen_driver_api_version(version)
  @api_version = version
end

.no_parallel_for(*methods) ⇒ Object

Registers certain driver actions that cannot be safely run concurrently in threads across multiple instances. Typically this might be used for create or destroy actions that use an underlying resource that cannot be used at the same time.

A shared mutex for this driver object will be used to synchronize all registered methods.

Examples:

a single action method that cannot be run concurrently


no_parallel_for :create

multiple action methods that cannot be run concurrently


no_parallel_for :create, :destroy

Raises:

  • (ClientError)

    if any method is not a valid action method name



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/kitchen/driver/base.rb', line 79

def self.no_parallel_for(*methods)
  action_methods = [:create, :setup, :verify, :destroy]

  Array(methods).each do |meth|
    next if action_methods.include?(meth)

    raise ClientError, "##{meth} is not a valid no_parallel_for method"
  end

  @serial_actions ||= []
  @serial_actions += methods
end

Instance Method Details

#create(state) ⇒ Object

Creates an instance.

Raises:



45
46
# File 'lib/kitchen/driver/base.rb', line 45

def create(state) # rubocop:disable Lint/UnusedMethodArgument
end

#destroy(state) ⇒ Object

Destroys an instance.

Raises:



52
53
# File 'lib/kitchen/driver/base.rb', line 52

def destroy(state) # rubocop:disable Lint/UnusedMethodArgument
end