Class: Kitchen::Driver::Base

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

Overview

Base class for a driver.

Direct Known Subclasses

Dummy, Exec, Proxy

Instance Attribute Summary

Attributes included from Configurable

#instance

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ShellOut

#run_command

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.

Parameters:

  • config (Hash) (defaults to: {})

    provided driver configuration



35
36
37
# File 'lib/kitchen/driver/base.rb', line 35

def initialize(config = {})
  init_config(config)
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

Examples:

setting an API version


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

      kitchen_driver_api_version 2

    end
  end
end

Parameters:

  • version (Integer, String)

    a version number



104
105
106
# File 'lib/kitchen/driver/base.rb', line 104

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

Instance Method Details

#cache_directoryObject

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



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

def cache_directory; end

#create(state) ⇒ Object

Creates an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



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

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

#destroy(state) ⇒ Object

Destroys an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



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

def destroy(state); end

#doctor(state) ⇒ Object

Check system and configuration for common errors.

Parameters:

  • state (Hash)

    mutable instance and driver state



63
64
65
# File 'lib/kitchen/driver/base.rb', line 63

def doctor(state)
  false
end

#package(state) ⇒ Object

Package an instance.

Parameters:

  • state (Hash)

    mutable instance and driver state

Raises:



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

def package(state); end

#status(state) ⇒ Hash

Reports whether the backing instance is known to be live.

Drivers that can ask their provider should override this method. Existing drivers remain compatible by inheriting an unknown status.

Parameters:

  • state (Hash)

    mutable instance and driver state

Returns:

  • (Hash)

    normalized status data



74
75
76
77
78
79
80
81
82
83
# File 'lib/kitchen/driver/base.rb', line 74

def status(state) # rubocop:disable Lint/UnusedMethodArgument
  {
    live: nil,
    state: "unknown",
    source: "driver",
    resource_id: nil,
    message: "#{self.class} does not support status checks",
    checked_at: Time.now.utc.iso8601,
  }
end