Skip to content

Commit

Permalink
Improve error on unknown role in accessories config.
Browse files Browse the repository at this point in the history
Previously when unknown role (or with typo) was placed in accessories.roles,
this error was thrown: `ERROR (NoMethodError): undefined method `hosts' for nil`.
  • Loading branch information
morgoth committed Nov 5, 2024
1 parent 9cf8da6 commit e4ab2a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/kamal/configuration/accessory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def hosts_from_hosts

def hosts_from_roles
if accessory_config.key?("roles")
accessory_config["roles"].flat_map { |role| config.role(role).hosts }
accessory_config["roles"].flat_map do |role|
config.role(role)&.hosts || raise(Kamal::ConfigurationError, "Unknown role in accessories config: '#{role}'")
end
end
end

Expand Down

0 comments on commit e4ab2a0

Please sign in to comment.