* main: (32 commits) Inline default as with other options Symbols! Fix tests test stop with custom stop wait time No need to replicate Docker default Describe purpose rather than elements Style and ordering Customizable stop wait time Fix tests Ensure it also works when configuring just log options without setting a driver Add accessory test Undo change Improve test Update README Ensure default log option `max-size=10m` #142 Allow to customize container options in accessories Fix flaky test Fix tests More resilient tests Fix other tests ...
55 lines
1.2 KiB
Ruby
55 lines
1.2 KiB
Ruby
module Mrsk::Commands
|
|
class Base
|
|
delegate :redact, :argumentize, to: Mrsk::Utils
|
|
|
|
attr_accessor :config
|
|
|
|
def initialize(config)
|
|
@config = config
|
|
end
|
|
|
|
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
|
|
|
|
def container_id_for(container_name:)
|
|
docker :container, :ls, "--all", "--filter", "name=#{container_name}", "--quiet"
|
|
end
|
|
|
|
private
|
|
def combine(*commands, by: "&&")
|
|
commands
|
|
.compact
|
|
.collect { |command| Array(command) + [ by ] }.flatten # Join commands
|
|
.tap { |commands| commands.pop } # Remove trailing combiner
|
|
end
|
|
|
|
def chain(*commands)
|
|
combine *commands, by: ";"
|
|
end
|
|
|
|
def pipe(*commands)
|
|
combine *commands, by: "|"
|
|
end
|
|
|
|
def append(*commands)
|
|
combine *commands, by: ">>"
|
|
end
|
|
|
|
def write(*commands)
|
|
combine *commands, by: ">"
|
|
end
|
|
|
|
def xargs(command)
|
|
[ :xargs, command ].flatten
|
|
end
|
|
|
|
def docker(*args)
|
|
args.compact.unshift :docker
|
|
end
|
|
end
|
|
end
|