From e178907a214143f2325ce46f0dd89880f0e3c1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BChlmann?= Date: Thu, 9 Mar 2023 16:46:57 +0100 Subject: [PATCH] Don't list duplicate hosts --- lib/mrsk/configuration.rb | 4 ++-- test/configuration_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mrsk/configuration.rb b/lib/mrsk/configuration.rb index 64c116a2..e1e15f94 100644 --- a/lib/mrsk/configuration.rb +++ b/lib/mrsk/configuration.rb @@ -64,7 +64,7 @@ class Mrsk::Configuration def all_hosts - roles.flat_map(&:hosts) + roles.flat_map(&:hosts).uniq end def primary_web_host @@ -72,7 +72,7 @@ class Mrsk::Configuration end def traefik_hosts - roles.select(&:running_traefik?).flat_map(&:hosts) + roles.select(&:running_traefik?).flat_map(&:hosts).uniq end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 5cd7856b..9c1aefec 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -15,7 +15,7 @@ class ConfigurationTest < ActiveSupport::TestCase @config = Mrsk::Configuration.new(@deploy) @deploy_with_roles = @deploy.dup.merge({ - servers: { "web" => [ "1.1.1.1", "1.1.1.2" ], "workers" => { "hosts" => [ "1.1.1.3", "1.1.1.4" ] } } }) + servers: { "web" => [ "1.1.1.1", "1.1.1.2" ], "workers" => { "hosts" => [ "1.1.1.1", "1.1.1.3" ] } } }) @config_with_roles = Mrsk::Configuration.new(@deploy_with_roles) end @@ -48,7 +48,7 @@ class ConfigurationTest < ActiveSupport::TestCase test "all hosts" do assert_equal [ "1.1.1.1", "1.1.1.2"], @config.all_hosts - assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], @config_with_roles.all_hosts + assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], @config_with_roles.all_hosts end test "primary web host" do @@ -62,7 +62,7 @@ class ConfigurationTest < ActiveSupport::TestCase @deploy_with_roles[:servers]["workers"]["traefik"] = true config = Mrsk::Configuration.new(@deploy_with_roles) - assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], config.traefik_hosts + assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], config.traefik_hosts end test "version" do