Pass around Roles instead of Strings

Avoid looking up roles by names everywhere. This avoids the awkward
role/role_config naming as well.
This commit is contained in:
Donal McBreen
2024-03-08 08:44:35 +00:00
parent 52bb40add0
commit 4966d52919
12 changed files with 61 additions and 60 deletions

View File

@@ -53,7 +53,7 @@ class Kamal::Commander
def primary_host
# Given a list of specific roles, make an effort to match up with the primary_role
specific_hosts&.first || specific_roles&.detect { |role| role.name == config.primary_role }&.primary_host || specific_roles&.first&.primary_host || config.primary_host
specific_hosts&.first || specific_roles&.detect { |role| role == config.primary_role }&.primary_host || specific_roles&.first&.primary_host || config.primary_host
end
def primary_role
@@ -73,7 +73,7 @@ class Kamal::Commander
end
def roles_on(host)
roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name)
roles.select { |role| role.hosts.include?(host.to_s) }
end
def traefik_hosts