class Kitchen::Driver::Base

Base class for a driver.

@author Fletcher Nichol <fnichol@nichol.ca>

Public Class Methods

kitchen_driver_api_version(version) click to toggle source

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

@example setting an API version

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

      kitchen_driver_api_version 2

    end
  end
end

@param version [Integer,String] a version number

# File lib/kitchen/driver/base.rb, line 92
def self.kitchen_driver_api_version(version)
  @api_version = version
end
new(config = {}) click to toggle source

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

@param config [Hash] provided driver configuration

# File lib/kitchen/driver/base.rb, line 41
def initialize(config = {})
  init_config(config)
end

Public Instance Methods

cache_directory() click to toggle source

Cache directory that a driver could implement to inform the provisioner that it can leverage it internally

@return path [String] a path of the cache directory

# File lib/kitchen/driver/base.rb, line 100
def cache_directory; end
create(state) click to toggle source

Creates an instance.

@param state [Hash] mutable instance and driver state @raise [ActionFailed] if the action could not be completed

# File lib/kitchen/driver/base.rb, line 49
def create(state) # rubocop:disable Lint/UnusedMethodArgument
  pre_create_command
end
destroy(state) click to toggle source

Destroys an instance.

@param state [Hash] mutable instance and driver state @raise [ActionFailed] if the action could not be completed

# File lib/kitchen/driver/base.rb, line 57
def destroy(state); end
doctor(state) click to toggle source

Check system and configuration for common errors.

@param state [Hash] mutable instance and driver state @returns [Boolean] Return true if a problem is found.

# File lib/kitchen/driver/base.rb, line 69
def doctor(state)
  false
end
package(state) click to toggle source

Package an instance.

@param state [Hash] mutable instance and driver state @raise [ActionFailed] if the action could not be completed

# File lib/kitchen/driver/base.rb, line 63
def package(state); end

Private Instance Methods

pre_create_command() click to toggle source

Run command if config is set

# File lib/kitchen/driver/base.rb, line 105
def pre_create_command
  if config[:pre_create_command]
    begin
      run_command(config[:pre_create_command])
    rescue ShellCommandFailed => error
      raise ActionFailed,
        "pre_create_command '#{config[:pre_create_command]}' failed to execute #{error}"
    end
  end
end
print(msg) click to toggle source

Intercepts any bare print calls in subclasses and issues an INFO log event instead.

@param msg [String] message string

puts(msg) click to toggle source

Intercepts any bare puts calls in subclasses and issues an INFO log event instead.

@param msg [String] message string

# File lib/kitchen/driver/base.rb, line 120
def puts(msg)
  info(msg)
end