Skip to content

Commit

Permalink
Replaced Kamal::Commands::Proxy::Exec with Kamal::Commands::App::Prox…
Browse files Browse the repository at this point in the history
…y and Kamal::Commands::Accessory::Proxy
  • Loading branch information
igor-alexandrov committed Nov 21, 2024
1 parent 14068b3 commit f367ca8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
6 changes: 1 addition & 5 deletions lib/kamal/commands/accessory.rb
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -111,10 +111,6 @@ def ensure_env_directory
end

private
def proxy_deploy_command_args(target:)
proxy.deploy_command_args(target: target)
end

def service_filter
[ "--filter", "label=service=#{service_name}" ]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 1 addition & 9 deletions lib/kamal/commands/app.rb
Original file line number Diff line number Diff line change
@@ -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 ]

Expand Down Expand Up @@ -76,14 +76,6 @@ def ensure_env_directory
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
Expand Down
16 changes: 16 additions & 0 deletions lib/kamal/commands/app/proxy.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f367ca8

Please sign in to comment.