Class: Kitchen::Transport::Dockercli::Connection

Inherits:
Base::Connection
  • Object
show all
Includes:
ShellOut
Defined in:
lib/kitchen/transport/dockercli.rb

Instance Method Summary collapse

Instance Method Details

#download(remotes, local) ⇒ Object


45
46
47
# File 'lib/kitchen/transport/dockercli.rb', line 45

def download(remotes, local)
  raise "Download not supported."
end

#execute(command) ⇒ Object


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kitchen/transport/dockercli.rb', line 24

def execute(command)
  return if command.nil?
  debug command
  tempfile = File.join(ENV['TEMP'], "#{SecureRandom.hex(4)}.ps1")
  begin
    File.open((tempfile), 'w') { |file| file.write(command) }
    dockered_command = "docker exec #{options[:container_id]} powershell.exe -noprofile -executionpolicy unrestricted -file #{tempfile}"
    run_command(dockered_command)
  ensure
    File.unlink(tempfile)
  end
end

#login_commandObject


49
50
51
# File 'lib/kitchen/transport/dockercli.rb', line 49

def 
  LoginCommand.new("docker exec -it #{options[:container_id]} powershell.exe -noprofile -executionpolicy unresticted", nil)
end

#upload(locals, remote) ⇒ Object


37
38
39
40
41
42
43
# File 'lib/kitchen/transport/dockercli.rb', line 37

def upload(locals, remote)
  powershell_commands = Array.new 
  Array(locals).each do |local|
    powershell_commands << "copy-item #{local} #{remote} -force -recurse;"
  end
  execute(powershell_commands.join)
end