diff --git a/lib/kamal/commander/specifics.rb b/lib/kamal/commander/specifics.rb index 88d89a72..127bd40e 100644 --- a/lib/kamal/commander/specifics.rb +++ b/lib/kamal/commander/specifics.rb @@ -19,7 +19,7 @@ class Kamal::Commander::Specifics end def traefik_hosts - specific_hosts || config.traefik_hosts + config.traefik_hosts & specified_hosts end def accessory_hosts diff --git a/test/commander_test.rb b/test/commander_test.rb index c8dd0517..2bbdb479 100644 --- a/test/commander_test.rb +++ b/test/commander_test.rb @@ -131,6 +131,20 @@ class CommanderTest < ActiveSupport::TestCase assert_equal [ "1.1.1.3", "1.1.1.4", "1.1.1.1", "1.1.1.2" ], @kamal.hosts end + test "traefik hosts should observe filtered roles" do + configure_with(:deploy_with_aliases) + + @kamal.specific_roles = [ "web_tokyo" ] + assert_equal [ "1.1.1.3", "1.1.1.4" ], @kamal.traefik_hosts + end + + test "traefik hosts should observe filtered hosts" do + configure_with(:deploy_with_aliases) + + @kamal.specific_hosts = [ "1.1.1.4" ] + assert_equal [ "1.1.1.4" ], @kamal.traefik_hosts + end + private def configure_with(variant) @kamal = Kamal::Commander.new.tap do |kamal| diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 36a9f305..6a86b231 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -83,6 +83,15 @@ class ConfigurationTest < ActiveSupport::TestCase assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], config.traefik_hosts end + test "filtered traefik hosts" do + assert_equal [ "1.1.1.1", "1.1.1.2" ], @config_with_roles.traefik_hosts + + @deploy_with_roles[:servers]["workers"]["traefik"] = true + config = Kamal::Configuration.new(@deploy_with_roles) + + assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], config.traefik_hosts + end + test "version no git repo" do ENV.delete("VERSION")