Class: Kitchen::Transport::ExpressSsh

Inherits:
Ssh
  • Object
show all
Defined in:
lib/kitchen/transport/express_ssh.rb

Overview

Express SSH Transport plugin for Test Kitchen

Defined Under Namespace

Classes: Connection

Instance Method Summary collapse

Instance Method Details

#create_new_connection(options, &block) ⇒ Ssh::Connection

Override the method in the super class to start the connection with our connection class

Parameters:

  • options (Hash)

    connection options

Returns:

  • (Ssh::Connection)

    an instance of Kitchen::Transport::ExpressSsh::Connection



52
53
54
55
56
57
58
59
60
# File 'lib/kitchen/transport/express_ssh.rb', line 52

def create_new_connection(options, &block)
  if @connection
    logger.debug("[#{Express::LOG_PREFIX}] Shutting previous connection #{@connection}")
    @connection.close
  end

  @connection_options = options
  @connection = self.class::Connection.new(options, &block)
end

#finalize_config!(instance) ⇒ Object

Finalizes the Kitchen config by executing super and parsing the options provided by the kitchen.yml The only difference here is we layer in our ssh options so the verifier can use our transport (see Kitchen::Transport::Ssh#finalize_config!)



73
74
75
76
77
78
79
80
81
# File 'lib/kitchen/transport/express_ssh.rb', line 73

def finalize_config!(instance)
  super.tap do
    if verifier_defined?(instance)
      instance.verifier.send(:define_singleton_method, :runner_options_for_expressssh) do |config_data|
        runner_options_for_ssh(config_data)
      end
    end
  end
end

#verifier_defined?(instance) ⇒ Boolean

Determines if the Kitchen instance is attempting a Verify stage

Parameters:

  • instance (Kitchen::Instance)

    the instance passed in from Kitchen

Returns:

  • (Boolean)


66
67
68
# File 'lib/kitchen/transport/express_ssh.rb', line 66

def verifier_defined?(instance)
  defined?(Kitchen::Verifier::Inspec) && instance.verifier.is_a?(Kitchen::Verifier::Inspec)
end