Add exec and bash commands to accessories

This commit is contained in:
David Heinemeier Hansson
2023-01-23 12:45:20 +01:00
parent 747e0fd4c2
commit ddf52da132
2 changed files with 46 additions and 0 deletions

View File

@@ -50,6 +50,29 @@ class Mrsk::Commands::Accessory < Mrsk::Commands::Base
if Pathname.new(local).exist?
[ :mkdir, "-p", Pathname.new(remote).dirname.to_s ]
else
def exec(*command, interactive: false)
docker :exec,
("-it" if interactive),
*env_args,
*volume_args,
service_name,
*command
end
def run_exec(*command, interactive: false)
docker :run,
("-it" if interactive),
"--rm",
*env_args,
*volume_args,
image,
*command
end
def bash(host:)
exec_over_ssh "bash", host: host
end
raise "Missing file: #{local}"
end
end
@@ -67,6 +90,10 @@ class Mrsk::Commands::Accessory < Mrsk::Commands::Base
end
private
def exec_over_ssh(*command, host:)
run_over_ssh run_exec(*command, interactive: true).join(" "), host: host
end
def service_filter
[ "--filter", "label=service=#{service_name}" ]
end