class Kitchen::Transport::Dokken
A Transport
which uses Docker tricks to execute commands and transfer files.
@author Sean OMeara <sean@sean.io>
Public Instance Methods
Source
# File lib/kitchen/transport/dokken.rb, line 58 def connection(state, &block) options = connection_options(config.to_hash.merge(state)) if @connection && @connection_options == options reuse_connection(&block) else create_new_connection(options, &block) end end
(see Base#connection)
Source
# File lib/kitchen/transport/dokken.rb, line 220 def docker_for_mac_or_win? ::Docker.info(::Docker::Connection.new(config[:docker_host_url], {}))["Name"] == "docker-desktop" rescue false end
Detect whether or not we are running in Docker for Mac or Windows
@return [TrueClass,FalseClass]
Private Instance Methods
Source
# File lib/kitchen/transport/dokken.rb, line 234 def connection_options(data) opts = {} opts[:logger] = logger opts[:host_ip_override] = config[:host_ip_override] opts[:docker_host_url] = config[:docker_host_url] opts[:docker_host_options] = ::Docker.options opts[:data_container] = data[:data_container] opts[:instance_name] = data[:instance_name] opts[:timeout] = data[:write_timeout] opts[:login_command] = data[:login_command] opts end
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
Source
# File lib/kitchen/transport/dokken.rb, line 253 def create_new_connection(options, &block) if @connection logger.debug("[Dokken] shutting previous connection #{@connection}") @connection.close end @connection = Kitchen::Transport::Dokken::Connection.new(options, &block) end
Creates a new Dokken
Connection
instance and save it for potential future reuse.
@param options [Hash] connection options @return [Ssh::Connection] an SSH Connection
instance @api private
Source
# File lib/kitchen/transport/dokken.rb, line 266 def reuse_connection logger.debug("[Dokken] reusing existing connection #{@connection}") yield @connection if block_given? @connection end
Return the last saved Dokken
connection instance.
@return [Dokken::Connection] an Dokken
Connection
instance @api private