class Kitchen::Transport::Base

Base class for a transport.

@author Salim Afiune <salim@afiunemaya.com.mx> @author Fletcher Nichol <fnichol@nichol.ca>

Public Class Methods

kitchen_transport_api_version(version) click to toggle source

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

Sets the API version for this transport

@example setting an API version

module Kitchen
  module Transport
    class NewTransport < Kitchen::Transport::Base

      kitchen_transport_api_version 2

    end
  end
end

@param version [Integer,String] a version number

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

Create a new transport by providing a configuration hash.

@param config [Hash] initial provided configuration

# File lib/kitchen/transport/base.rb, line 51
def initialize(config = {})
  @connection = nil
  init_config(config)
end

Public Instance Methods

cleanup!() click to toggle source

Closes the connection, if it is still active.

@return [void]

# File lib/kitchen/transport/base.rb, line 80
def cleanup!
  # This method may be left unimplemented if that is applicable
end
connection(state) click to toggle source

Creates a new Connection, configured by a merging of configuration and state data. Depending on the implementation, the Connection could be saved or cached to speed up multiple calls, given the same state hash as input.

@param state [Hash] mutable instance state @return [Connection] a connection for this transport @raise [TransportFailed] if a connection could not be returned rubocop:disable Lint/UnusedMethodArgument

# File lib/kitchen/transport/base.rb, line 65
def connection(state)
  raise ClientError, "#{self.class}#connection must be implemented"
end
doctor(state) click to toggle source

Check system and configuration for common errors.

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

# File lib/kitchen/transport/base.rb, line 73
def doctor(state)
  false
end