Class: Kitchen::Transport::Dockercli::Connection
- Inherits:
-
Base::Connection
- Object
- Base::Connection
- Kitchen::Transport::Dockercli::Connection
- Includes:
- ShellOut
- Defined in:
- lib/kitchen/transport/dockercli.rb
Instance Method Summary collapse
- #download(remotes, local) ⇒ Object
- #execute(command) ⇒ Object
- #login_command ⇒ Object
- #upload(locals, remote) ⇒ Object
Instance Method Details
#download(remotes, local) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/kitchen/transport/dockercli.rb', line 46 def download(remotes, local) powershell_commands = Array.new Array(remotes).each do |remote| powershell_commands << "copy-item #{remote} #{translate_path(local)} -force -recurse;" end execute(powershell_commands.join) end |
#execute(command) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kitchen/transport/dockercli.rb', line 24 def execute(command) return if command.nil? tempfile = "#{SecureRandom.hex(4)}.ps1" tempfile_path = File.join(ENV['TEMP'], tempfile) translated_path = translate_path(tempfile_path) begin File.open((tempfile_path), 'w') { |file| file.write(command) } dockered_command = "docker exec #{options[:container_id]} powershell.exe -noprofile -noninteractive -executionpolicy unrestricted -file #{translated_path}" run_command(dockered_command) ensure File.unlink(tempfile_path) end end |
#login_command ⇒ Object
54 55 56 |
# File 'lib/kitchen/transport/dockercli.rb', line 54 def login_command LoginCommand.new("docker exec -it #{options[:container_id]} powershell.exe -noprofile -executionpolicy unresticted", nil) end |
#upload(locals, remote) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/kitchen/transport/dockercli.rb', line 38 def upload(locals, remote) powershell_commands = Array.new Array(locals).each do |local| powershell_commands << "copy-item #{translate_path(local)} #{remote} -force -recurse;" end execute(powershell_commands.join) end |