Merge pull request #988 from igor-alexandrov/kamal-proxy-remove-no-target

Fixed kamal-proxy remove command
This commit is contained in:
Donal McBreen
2024-09-30 04:18:12 -04:00
committed by GitHub
6 changed files with 13 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
version = capture_with_info(*app.current_running_version, raise_on_non_zero_exit: false).strip version = capture_with_info(*app.current_running_version, raise_on_non_zero_exit: false).strip
endpoint = capture_with_info(*app.container_id_for_version(version)).strip endpoint = capture_with_info(*app.container_id_for_version(version)).strip
if endpoint.present? if endpoint.present?
execute *app.remove(target: endpoint), raise_on_non_zero_exit: false execute *app.remove, raise_on_non_zero_exit: false
end end
end end

View File

@@ -5,8 +5,8 @@ module Kamal::Commands::App::Proxy
proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target) proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target)
end end
def remove(target:) def remove
proxy_exec :remove, role.container_prefix, *role.proxy.remove_command_args(target: target) proxy_exec :remove, role.container_prefix
end end
private private

View File

@@ -51,10 +51,6 @@ class Kamal::Configuration::Proxy
optionize ({ target: "#{target}:#{app_port}" }).merge(deploy_options) optionize ({ target: "#{target}:#{app_port}" }).merge(deploy_options)
end end
def remove_command_args(target:)
optionize({ target: "#{target}:#{app_port}" })
end
def merge(other) def merge(other)
self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config) self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config)
end end

View File

@@ -121,8 +121,8 @@ class CommandsAppTest < ActiveSupport::TestCase
test "remove" do test "remove" do
assert_equal \ assert_equal \
"docker exec kamal-proxy kamal-proxy remove app-web --target \"172.1.0.2:80\"", "docker exec kamal-proxy kamal-proxy remove app-web",
new_command.remove(target: "172.1.0.2").join(" ") new_command.remove.join(" ")
end end

View File

@@ -8,7 +8,7 @@ class AppTest < IntegrationTest
kamal :app, :stop kamal :app, :stop
assert_app_is_down assert_app_not_found
kamal :app, :start kamal :app, :start
@@ -48,7 +48,7 @@ class AppTest < IntegrationTest
kamal :app, :remove kamal :app, :remove
assert_app_is_down assert_app_not_found
assert_app_directory_removed assert_app_directory_removed
end end
end end

View File

@@ -50,6 +50,12 @@ class IntegrationTest < ActiveSupport::TestCase
assert_equal "502", response.code assert_equal "502", response.code
end end
def assert_app_not_found
response = app_response
debug_response_code(response, "404")
assert_equal "404", response.code
end
def assert_app_is_up(version: nil, app: @app) def assert_app_is_up(version: nil, app: @app)
response = app_response(app: app) response = app_response(app: app)
debug_response_code(response, "200") debug_response_code(response, "200")