class Kitchen::Transport::Train

Public Instance Methods

connection(state, &block) click to toggle source
# File lib/kitchen/transport/train.rb, line 18
def connection(state, &block)
  options = connection_options(config.to_hash.merge(state))
  options = adjust_options(options)

  Kitchen::Transport::Train::Connection.new(options, &block)
end

Private Instance Methods

adjust_options(data) click to toggle source

Map Kitchen parameters to their Train equivalents for compatibility.

# File lib/kitchen/transport/train.rb, line 92
def adjust_options(data)
  if data[:backend] == "ssh"
    data[:key_files] = data[:ssh_key]
    data.delete(:ssh_key)
  end

  data
end
connection_options(data) click to toggle source

Builds the hash of options needed by the Connection object on construction.

@param data [Hash] merged configuration and mutable state data @return [Hash] hash of connection options @api private

# File lib/kitchen/transport/train.rb, line 73
def connection_options(data)
  # `windows_os?` comes from Kitchen::Configurable, which is included in the Kitchen base transport
  defaults = {
    backend: windows_os? ? "winrm" : "ssh",
  }

  overrides = {
    instance_name: instance.name,
    kitchen_root: Dir.pwd,

    # Kitchen to Train parameter conversion
    host: data[:hostname],
    user: data[:username],
  }

  defaults.merge(data).merge(overrides)
end