Replaced Kamal::Commands::Proxy::Exec with Kamal::Commands::App::Proxy and Kamal::Commands::Accessory::Proxy

This commit is contained in:
Igor Alexandrov
2024-11-21 23:07:55 +04:00
parent 14068b32b1
commit f367ca8ea5
4 changed files with 20 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
class Kamal::Commands::Accessory < Kamal::Commands::Base
include Kamal::Commands::Proxy::Exec
include Proxy
attr_reader :accessory_config
delegate :service_name, :image, :hosts, :port, :files, :directories, :cmd,
@@ -111,10 +111,6 @@ 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

View File

@@ -1,8 +1,8 @@
module Kamal::Commands::Proxy::Exec
module Kamal::Commands::Accessory::Proxy
delegate :proxy_container_name, to: :config
def deploy(target:)
proxy_exec :deploy, service_name, *proxy_deploy_command_args(target: target)
proxy_exec :deploy, service_name, *proxy.deploy_command_args(target: target)
end
def remove

View File

@@ -1,5 +1,5 @@
class Kamal::Commands::App < Kamal::Commands::Base
include Assets, Containers, Execution, Images, Logging, Kamal::Commands::Proxy::Exec
include Assets, Containers, Execution, Images, Logging, Proxy
ACTIVE_DOCKER_STATUSES = [ :running, :restarting ]
@@ -76,14 +76,6 @@ 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

View File

@@ -0,0 +1,16 @@
module Kamal::Commands::App::Proxy
delegate :proxy_container_name, to: :config
def deploy(target:)
proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target)
end
def remove
proxy_exec :remove, role.container_prefix
end
private
def proxy_exec(*command)
docker :exec, proxy_container_name, "kamal-proxy", *command
end
end