Drop concerns
Not enough reuse possible
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
require "mrsk/commands/base"
|
||||
require "mrsk/commands/concerns"
|
||||
|
||||
class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
include Mrsk::Commands::Concerns::Executions
|
||||
|
||||
def run(role: :web)
|
||||
role = config.role(role)
|
||||
|
||||
@@ -23,10 +20,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
docker :start, service_with_version
|
||||
end
|
||||
|
||||
def current_container_id
|
||||
docker :ps, "-q", *service_filter
|
||||
end
|
||||
|
||||
def stop
|
||||
pipe current_container_id, xargs(docker(:stop))
|
||||
end
|
||||
@@ -35,6 +28,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
docker :ps, *service_filter
|
||||
end
|
||||
|
||||
|
||||
def logs(since: nil, lines: nil, grep: nil)
|
||||
pipe \
|
||||
current_container_id,
|
||||
@@ -50,6 +44,38 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
).join(" "), host: host
|
||||
end
|
||||
|
||||
|
||||
def execute_in_existing_container(*command, interactive: false)
|
||||
docker :exec,
|
||||
("-it" if interactive),
|
||||
config.service_with_version,
|
||||
*command
|
||||
end
|
||||
|
||||
def execute_in_new_container(*command, interactive: false)
|
||||
docker :run,
|
||||
("-it" if interactive),
|
||||
"--rm",
|
||||
*rails_master_key_arg,
|
||||
*config.env_args,
|
||||
*config.volume_args,
|
||||
config.absolute_image,
|
||||
*command
|
||||
end
|
||||
|
||||
def execute_in_existing_container_over_ssh(*command, host:)
|
||||
run_over_ssh execute_in_existing_container(*command, interactive: true).join(" "), host: host
|
||||
end
|
||||
|
||||
def execute_in_new_container_over_ssh(*command, host:)
|
||||
run_over_ssh execute_in_new_container(*command, interactive: true).join(" "), host: host
|
||||
end
|
||||
|
||||
|
||||
def current_container_id
|
||||
docker :ps, "-q", *service_filter
|
||||
end
|
||||
|
||||
def container_id_for(container_name:)
|
||||
docker :container, :ls, "-a", "-f", "name=#{container_name}", "-q"
|
||||
end
|
||||
@@ -68,6 +94,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
"head -n 1"
|
||||
end
|
||||
|
||||
|
||||
def list_containers
|
||||
docker :container, :ls, "-a", *service_filter
|
||||
end
|
||||
@@ -90,6 +117,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||
docker :image, :prune, "-a", "-f", *service_filter
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def service_with_version(version = nil)
|
||||
if version
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
module Mrsk::Commands::Concerns
|
||||
end
|
||||
|
||||
require "mrsk/commands/concerns/executions"
|
||||
@@ -1,27 +0,0 @@
|
||||
module Mrsk::Commands::Concerns::Executions
|
||||
def execute_in_existing_container(*command, interactive: false)
|
||||
docker :exec,
|
||||
("-it" if interactive),
|
||||
config.service_with_version,
|
||||
*command
|
||||
end
|
||||
|
||||
def execute_in_new_container(*command, interactive: false)
|
||||
docker :run,
|
||||
("-it" if interactive),
|
||||
"--rm",
|
||||
*rails_master_key_arg,
|
||||
*config.env_args,
|
||||
*config.volume_args,
|
||||
config.absolute_image,
|
||||
*command
|
||||
end
|
||||
|
||||
def execute_in_existing_container_over_ssh(*command, host:)
|
||||
run_over_ssh execute_in_existing_container(*command, interactive: true).join(" "), host: host
|
||||
end
|
||||
|
||||
def execute_in_new_container_over_ssh(*command, host:)
|
||||
run_over_ssh execute_in_new_container(*command, interactive: true).join(" "), host: host
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user