class Kitchen::Driver::Base
Base
class for a driver.
@author Fletcher Nichol <fnichol@nichol.ca>
Public Class Methods
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
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 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
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
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
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 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
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
Intercepts any bare print
calls in subclasses and issues an INFO log event instead.
@param msg [String] message string
# File lib/kitchen/driver/base.rb, line 128 def print(msg) info(msg) end
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