Extracted proxy commands to a module
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class Kamal::Commands::Accessory < Kamal::Commands::Base
|
||||
include Kamal::Commands::Proxy::Exec
|
||||
|
||||
attr_reader :accessory_config
|
||||
delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd,
|
||||
:network_args, :publish_args, :env_args, :volume_args, :label_args, :option_args,
|
||||
@@ -40,14 +42,6 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
||||
docker :ps, *service_filter
|
||||
end
|
||||
|
||||
def deploy(target:)
|
||||
proxy_exec :deploy, service_name, *proxy.deploy_command_args(target: target)
|
||||
end
|
||||
|
||||
def remove
|
||||
proxy_exec :remove, service_name
|
||||
end
|
||||
|
||||
|
||||
def logs(timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
|
||||
pipe \
|
||||
@@ -117,6 +111,10 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
private
|
||||
def proxy_deploy_command_args(target:)
|
||||
proxy.deploy_command_args(target: target)
|
||||
end
|
||||
|
||||
def service_filter
|
||||
[ "--filter", "label=service=#{service_name}" ]
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Kamal::Commands::App < Kamal::Commands::Base
|
||||
include Assets, Containers, Execution, Images, Logging, Proxy
|
||||
include Assets, Containers, Execution, Images, Logging, Kamal::Commands::Proxy::Exec
|
||||
|
||||
ACTIVE_DOCKER_STATUSES = [ :running, :restarting ]
|
||||
|
||||
@@ -76,6 +76,14 @@ class Kamal::Commands::App < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
private
|
||||
def service_name
|
||||
role.container_prefix
|
||||
end
|
||||
|
||||
def proxy_deploy_command_args(target:)
|
||||
role.proxy.deploy_command_args(target: target)
|
||||
end
|
||||
|
||||
def latest_image_id
|
||||
docker :image, :ls, *argumentize("--filter", "reference=#{config.latest_image}"), "--format", "'{{.ID}}'"
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module Kamal::Commands::App::Proxy
|
||||
module Kamal::Commands::Proxy::Exec
|
||||
delegate :proxy_container_name, to: :config
|
||||
|
||||
def deploy(target:)
|
||||
proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target)
|
||||
proxy_exec :deploy, service_name, *proxy_deploy_command_args(target: target)
|
||||
end
|
||||
|
||||
def remove
|
||||
proxy_exec :remove, role.container_prefix
|
||||
proxy_exec :remove, service_name
|
||||
end
|
||||
|
||||
private
|
||||
Reference in New Issue
Block a user