Raise an error when either the filtered hosts or roles are empty.

Keeps us confusingly running things on the primary_host when nothing
matches.
This commit is contained in:
Matthew Kent
2023-11-24 21:18:06 -08:00
parent 79baa598fa
commit 63babecba7
2 changed files with 31 additions and 6 deletions

View File

@@ -28,11 +28,27 @@ class Kamal::Commander
end
def specific_roles=(role_names)
@specific_roles = Kamal::Utils.filter_specific_items(role_names, config.roles) if role_names.present?
if role_names.present?
@specific_roles = Kamal::Utils.filter_specific_items(role_names, config.roles)
if @specific_roles.empty?
raise ArgumentError, "No --roles match for #{role_names.join(',')}"
end
@specific_roles
end
end
def specific_hosts=(hosts)
@specific_hosts = Kamal::Utils.filter_specific_items(hosts, config.all_hosts) if hosts.present?
if hosts.present?
@specific_hosts = Kamal::Utils.filter_specific_items(hosts, config.all_hosts)
if @specific_hosts.empty?
raise ArgumentError, "No --hosts match for #{hosts.join(',')}"
end
@specific_hosts
end
end
def primary_host