More natural api when you are just applying accessory to a single tag

This commit is contained in:
David Heinemeier Hansson
2025-05-09 21:47:26 +02:00
parent fb82d04aaf
commit 299c741c1b
4 changed files with 14 additions and 6 deletions

View File

@@ -207,7 +207,9 @@ class Kamal::Configuration::Accessory
end
def hosts_from_tags
if accessory_config.key?("tags")
if accessory_config.key?("tag")
extract_hosts_from_config_with_tag(accessory_config["tag"])
elsif accessory_config.key?("tags")
accessory_config["tags"].flat_map { |tag| extract_hosts_from_config_with_tag(tag) }
end
end

View File

@@ -53,8 +53,10 @@ accessories:
- mysql-db2
roles:
- mysql
tag: writer
tags:
- writer
- reader
# Custom command
#

View File

@@ -2,8 +2,8 @@ class Kamal::Configuration::Validator::Accessory < Kamal::Configuration::Validat
def validate!
super
if (config.keys & [ "host", "hosts", "roles", "tags" ]).size != 1
error "specify one of `host`, `hosts`, `roles` or `tags`"
if (config.keys & [ "host", "hosts", "roles", "tag", "tags" ]).size != 1
error "specify one of `host`, `hosts`, `roles`, `tag` or `tags`"
end
validate_docker_options!(config["options"])