From 04a96aa5bec3e0a502025fde7a1c4ba7cc991843 Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Mon, 3 Feb 2025 16:44:01 +0000 Subject: [PATCH] Allow accessory roles with no hosts Only raise an exception if the role is not found, not it it has no hosts. --- lib/kamal/configuration/accessory.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kamal/configuration/accessory.rb b/lib/kamal/configuration/accessory.rb index ccb845fd..aed60492 100644 --- a/lib/kamal/configuration/accessory.rb +++ b/lib/kamal/configuration/accessory.rb @@ -201,7 +201,11 @@ class Kamal::Configuration::Accessory def hosts_from_roles if accessory_config.key?("roles") accessory_config["roles"].flat_map do |role| - config.role(role)&.hosts || raise(Kamal::ConfigurationError, "Unknown role in accessories config: '#{role}'") + unless (role = config.role(role)) + raise Kamal::ConfigurationError, "Unknown role in accessories config: '#{role}'" unless config.role(role) + end + + role.hosts end end end