Skip to content

Commit

Permalink
Merge pull request #988 from igor-alexandrov/kamal-proxy-remove-no-ta…
Browse files Browse the repository at this point in the history
…rget

Fixed kamal-proxy remove command
  • Loading branch information
djmb authored Sep 30, 2024
2 parents b11fb93 + 6d63c4e commit 28a0226
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/kamal/cli/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def stop
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
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

Expand Down
4 changes: 2 additions & 2 deletions lib/kamal/commands/app/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def deploy(target:)
proxy_exec :deploy, role.container_prefix, *role.proxy.deploy_command_args(target: target)
end

def remove(target:)
proxy_exec :remove, role.container_prefix, *role.proxy.remove_command_args(target: target)
def remove
proxy_exec :remove, role.container_prefix
end

private
Expand Down
4 changes: 0 additions & 4 deletions lib/kamal/configuration/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ def deploy_command_args(target:)
optionize ({ target: "#{target}:#{app_port}" }).merge(deploy_options)
end

def remove_command_args(target:)
optionize({ target: "#{target}:#{app_port}" })
end

def merge(other)
self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config)
end
Expand Down
4 changes: 2 additions & 2 deletions test/commands/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ class CommandsAppTest < ActiveSupport::TestCase

test "remove" do
assert_equal \
"docker exec kamal-proxy kamal-proxy remove app-web --target \"172.1.0.2:80\"",
new_command.remove(target: "172.1.0.2").join(" ")
"docker exec kamal-proxy kamal-proxy remove app-web",
new_command.remove.join(" ")
end


Expand Down
4 changes: 2 additions & 2 deletions test/integration/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AppTest < IntegrationTest

kamal :app, :stop

assert_app_is_down
assert_app_not_found

kamal :app, :start

Expand Down Expand Up @@ -48,7 +48,7 @@ class AppTest < IntegrationTest

kamal :app, :remove

assert_app_is_down
assert_app_not_found
assert_app_directory_removed
end
end
6 changes: 6 additions & 0 deletions test/integration/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def assert_app_is_down
assert_equal "502", response.code
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)
response = app_response(app: app)
debug_response_code(response, "200")
Expand Down

0 comments on commit 28a0226

Please sign in to comment.