Class: Dip::Commands::SSH::Up

Inherits:
Dip::Command show all
Defined in:
lib/dip/commands/ssh.rb

Instance Method Summary collapse

Methods inherited from Dip::Command

exec_program, exec_subprocess

Constructor Details

#initialize(key:, volume:, interactive:, user: nil) ⇒ Up

Returns a new instance of Up.



10
11
12
13
14
15
# File 'lib/dip/commands/ssh.rb', line 10

def initialize(key:, volume:, interactive:, user: nil)
  @key = key
  @volume = volume
  @interactive = interactive
  @user = user
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dip/commands/ssh.rb', line 17

def execute
  exec_subprocess("docker", "volume create --name ssh_data", out: File::NULL, err: File::NULL)

  exec_subprocess(
    "docker",
    "run #{user_args}--detach --volume ssh_data:/ssh --name=ssh-agent whilp/ssh-agent"
  )

  key = Dip.env.interpolate(@key)
  exec_subprocess("docker", "run #{container_args} whilp/ssh-agent ssh-add #{key}")
end