Join in run_over_ssh instead of all over
This commit is contained in:
@@ -64,11 +64,11 @@ class Mrsk::Commands::Accessory < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_in_existing_container_over_ssh(*command)
|
def execute_in_existing_container_over_ssh(*command)
|
||||||
run_over_ssh execute_in_existing_container(*command, interactive: true).join(" ")
|
run_over_ssh execute_in_existing_container(*command, interactive: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute_in_new_container_over_ssh(*command)
|
def execute_in_new_container_over_ssh(*command)
|
||||||
run_over_ssh execute_in_new_container(*command, interactive: true).join(" ")
|
run_over_ssh execute_in_new_container(*command, interactive: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_over_ssh(command)
|
def run_over_ssh(command)
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def follow_logs(host:, grep: nil)
|
def follow_logs(host:, grep: nil)
|
||||||
run_over_ssh pipe(
|
run_over_ssh \
|
||||||
current_container_id,
|
pipe(
|
||||||
"xargs docker logs -t -n 10 -f 2>&1",
|
current_container_id,
|
||||||
(%(grep "#{grep}") if grep)
|
"xargs docker logs -t -n 10 -f 2>&1",
|
||||||
).join(" "), host: host
|
(%(grep "#{grep}") if grep)
|
||||||
|
),
|
||||||
|
host: host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -62,11 +64,11 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def execute_in_existing_container_over_ssh(*command, host:)
|
def execute_in_existing_container_over_ssh(*command, host:)
|
||||||
run_over_ssh execute_in_existing_container(*command, interactive: true).join(" "), host: host
|
run_over_ssh execute_in_existing_container(*command, interactive: true), host: host
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute_in_new_container_over_ssh(*command, host:)
|
def execute_in_new_container_over_ssh(*command, host:)
|
||||||
run_over_ssh execute_in_new_container(*command, interactive: true).join(" "), host: host
|
run_over_ssh execute_in_new_container(*command, interactive: true), host: host
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ module Mrsk::Commands
|
|||||||
@config = config
|
@config = config
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_over_ssh(command, host:)
|
def run_over_ssh(*command, host:)
|
||||||
"ssh -t #{config.ssh_user}@#{host} '#{command}'"
|
"ssh -t #{config.ssh_user}@#{host} '#{command.join(" ")}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -81,14 +81,14 @@ class CommandsAccessoryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "execute in new container over ssh" do
|
test "execute in new container over ssh" do
|
||||||
@mysql.stub(:run_over_ssh, ->(cmd) { cmd }) do
|
@mysql.stub(:run_over_ssh, ->(cmd) { cmd.join(" ") }) do
|
||||||
assert_match %r|docker run -it --rm -e MYSQL_ROOT_PASSWORD=secret123 -e MYSQL_ROOT_HOST=% mysql:8.0 mysql -u root|,
|
assert_match %r|docker run -it --rm -e MYSQL_ROOT_PASSWORD=secret123 -e MYSQL_ROOT_HOST=% mysql:8.0 mysql -u root|,
|
||||||
@mysql.execute_in_new_container_over_ssh("mysql", "-u", "root")
|
@mysql.execute_in_new_container_over_ssh("mysql", "-u", "root")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "execute in existing container over ssh" do
|
test "execute in existing container over ssh" do
|
||||||
@mysql.stub(:run_over_ssh, ->(cmd) { cmd }) do
|
@mysql.stub(:run_over_ssh, ->(cmd) { cmd.join(" ") }) do
|
||||||
assert_match %r|docker exec -it app-mysql mysql -u root|,
|
assert_match %r|docker exec -it app-mysql mysql -u root|,
|
||||||
@mysql.execute_in_existing_container_over_ssh("mysql", "-u", "root")
|
@mysql.execute_in_existing_container_over_ssh("mysql", "-u", "root")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ class CommandsAppTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "execute in new container over ssh" do
|
test "execute in new container over ssh" do
|
||||||
@app.stub(:run_over_ssh, ->(cmd, host:) { cmd }) do
|
@app.stub(:run_over_ssh, ->(cmd, host:) { cmd.join(" ") }) do
|
||||||
assert_match %r|docker run -it --rm -e RAILS_MASTER_KEY=456 dhh/app:missing bin/rails c|,
|
assert_match %r|docker run -it --rm -e RAILS_MASTER_KEY=456 dhh/app:missing bin/rails c|,
|
||||||
@app.execute_in_new_container_over_ssh("bin/rails", "c", host: "app-1")
|
@app.execute_in_new_container_over_ssh("bin/rails", "c", host: "app-1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "execute in existing container over ssh" do
|
test "execute in existing container over ssh" do
|
||||||
@app.stub(:run_over_ssh, ->(cmd, host:) { cmd }) do
|
@app.stub(:run_over_ssh, ->(cmd, host:) { cmd.join(" ") }) do
|
||||||
assert_match %r|docker exec -it app-missing bin/rails c|,
|
assert_match %r|docker exec -it app-missing bin/rails c|,
|
||||||
@app.execute_in_existing_container_over_ssh("bin/rails", "c", host: "app-1")
|
@app.execute_in_existing_container_over_ssh("bin/rails", "c", host: "app-1")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user