Class: Specinfra::Backend::Dockercli

Inherits:
Exec
  • Object
show all
Defined in:
lib/specinfra/backend/dockercli.rb

Overview

Docker command line transport

Instance Method Summary collapse

Methods inherited from Exec

#run_command

Methods inherited from Base

clear, #command, #get_config, #host_inventory, #initialize, instance, #os_info, #set_config, #set_example, #stderr_handler=, #stdout_handler=

Constructor Details

This class inherits a constructor from Specinfra::Backend::Base

Instance Method Details

#build_command(cmd) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/specinfra/backend/dockercli.rb', line 7

def build_command(cmd)
  docker_cmd = %w[docker exec]
  docker_cmd << '--interactive' if get_config(:interactive_shell)
  docker_cmd << '--tty' if get_config(:request_pty)
  docker_cmd << instance
  (docker_cmd << super(cmd)).join(' ')
end

#send_directory(from, to) ⇒ Object



21
22
23
# File 'lib/specinfra/backend/dockercli.rb', line 21

def send_directory(from, to)
  send_file(from, to)
end

#send_file(from, to) ⇒ Object



15
16
17
18
19
# File 'lib/specinfra/backend/dockercli.rb', line 15

def send_file(from, to)
  to = Pathname.new(to).dirname.to_s if File.directory?(from)
  cmd = %W[docker cp #{from} #{instance}:#{to}]
  spawn_command(cmd.join(' '))
end