class Kitchen::Transport::Dokken::Connection
def upload(locals, remote)
def upload(locals, remote) port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort] if options[:host_ip_override] # Allow connecting to any ip/hostname to support sibling containers ip = options[:host_ip_override] elsif options[:docker_host_url] =~ /unix:/ if options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp] == '0.0.0.0' ip = options[:data_container][:NetworkSettings][:IPAddress] port = '22' else # we should read the proper mapped ip, since this allows us to upload the files ip = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp] end elsif options[:docker_host_url] =~ /tcp:/ ip = options[:docker_host_url].split('tcp://')[1].split(':')[0] else raise Kitchen::UserError, 'docker_host_url must be tcp:// or unix://' end tmpdir = Dir.tmpdir FileUtils.mkdir_p "#{tmpdir}/dokken" File.write("#{tmpdir}/dokken/id_rsa", insecure_ssh_private_key) FileUtils.chmod(0600, "#{tmpdir}/dokken/id_rsa") begin rsync_cmd = '/usr/bin/rsync -a -e' rsync_cmd << ' \'' rsync_cmd << 'ssh -2' rsync_cmd << " -i #{tmpdir}/dokken/id_rsa" rsync_cmd << ' -o CheckHostIP=no' rsync_cmd << ' -o Compression=no' rsync_cmd << ' -o PasswordAuthentication=no' rsync_cmd << ' -o StrictHostKeyChecking=no' rsync_cmd << ' -o UserKnownHostsFile=/dev/null' rsync_cmd << ' -o LogLevel=ERROR' rsync_cmd << " -p #{port}" rsync_cmd << '\'' rsync_cmd << " #{locals.join(' ')} root@#{ip}:#{remote}" `#{rsync_cmd}` rescue Errno::ENOENT debug 'Rsync is not installed. Falling back to SCP.' locals.each do |local| Net::SCP.upload!(ip, 'root', local, remote, recursive: true, ssh: { port: port, keys: ["#{tmpdir}/dokken/id_rsa"] }) end end end