Class: Mrsk::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mrsk/commands/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/mrsk/commands/base.rb', line 7

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/mrsk/commands/base.rb', line 5

def config
  @config
end

Instance Method Details

#container_id_for(container_name:) ⇒ Object



18
19
20
# File 'lib/mrsk/commands/base.rb', line 18

def container_id_for(container_name:)
  docker :container, :ls, "--all", "--filter", "name=^#{container_name}$", "--quiet"
end

#run_over_ssh(*command, host:) ⇒ Object



11
12
13
14
15
16
# File 'lib/mrsk/commands/base.rb', line 11

def run_over_ssh(*command, host:)
  "ssh".tap do |cmd|
    cmd << " -J #{config.ssh_proxy.jump_proxies}" if config.ssh_proxy
    cmd << " -t #{config.ssh_user}@#{host} '#{command.join(" ")}'"
  end
end