Class: Vx::ContainerConnector::Docker::Spawner

Inherits:
Object
  • Object
show all
Defined in:
lib/vx/container_connector/docker/spawner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, ssh, work_dir) ⇒ Spawner

Returns a new instance of Spawner.



9
10
11
12
13
# File 'lib/vx/container_connector/docker/spawner.rb', line 9

def initialize(container, ssh, work_dir)
  @container  = container
  @ssh        = ssh
  @work_dir   = work_dir
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



7
8
9
# File 'lib/vx/container_connector/docker/spawner.rb', line 7

def container
  @container
end

#sshObject (readonly)

Returns the value of attribute ssh.



7
8
9
# File 'lib/vx/container_connector/docker/spawner.rb', line 7

def ssh
  @ssh
end

#work_dirObject (readonly)

Returns the value of attribute work_dir.



7
8
9
# File 'lib/vx/container_connector/docker/spawner.rb', line 7

def work_dir
  @work_dir
end

Instance Method Details

#idObject



25
26
27
# File 'lib/vx/container_connector/docker/spawner.rb', line 25

def id
  container.id
end

#spawn(*args, &logger) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/vx/container_connector/docker/spawner.rb', line 15

def spawn(*args, &logger)
  env     = args.first.is_a?(Hash) ? args.shift : {}
  options = args.last.is_a?(Hash)  ? args.pop   : {}
  cmd     = args

  options.merge!(chdir: work_dir, pty: true)

  ssh.spawn(env, cmd, options, &logger)
end