Class: Kitchen::Transport::Base

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

Overview

Base class for a transport.

Direct Known Subclasses

Dummy, Exec, Ssh, Winrm

Defined Under Namespace

Classes: Connection

Instance Attribute Summary

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

Create a new transport by providing a configuration hash.

Parameters:

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

    initial provided configuration



50
51
52
53
# File 'lib/kitchen/transport/base.rb', line 50

def initialize(config = {})
  @connection = nil
  init_config(config)
end

Class Method Details

.kitchen_transport_api_version(version) ⇒ Object

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

Examples:

setting an API version


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

      kitchen_transport_api_version 2

    end
  end
end

Parameters:

  • version (Integer, String)

    a version number



226
227
228
# File 'lib/kitchen/transport/base.rb', line 226

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

Instance Method Details

#cleanup!void

This method returns an undefined value.

Closes the connection, if it is still active.



79
80
81
# File 'lib/kitchen/transport/base.rb', line 79

def cleanup!
  # This method may be left unimplemented if that is applicable
end

#connection(state) ⇒ Connection

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.

rubocop:disable Lint/UnusedMethodArgument

Parameters:

  • state (Hash)

    mutable instance state

Returns:

  • (Connection)

    a connection for this transport

Raises:



64
65
66
# File 'lib/kitchen/transport/base.rb', line 64

def connection(state)
  raise ClientError, "#{self.class}#connection must be implemented"
end

#doctor(state) ⇒ Object

Check system and configuration for common errors.

Parameters:

  • state (Hash)

    mutable instance state



72
73
74
# File 'lib/kitchen/transport/base.rb', line 72

def doctor(state)
  false
end