Pin accessories to tags
This commit is contained in:
@@ -32,7 +32,7 @@ class Kamal::Configuration::Accessory
|
||||
end
|
||||
|
||||
def hosts
|
||||
hosts_from_host || hosts_from_hosts || hosts_from_roles
|
||||
hosts_from_host || hosts_from_hosts || hosts_from_roles || hosts_from_tags
|
||||
end
|
||||
|
||||
def port
|
||||
@@ -206,6 +206,12 @@ class Kamal::Configuration::Accessory
|
||||
end
|
||||
end
|
||||
|
||||
def hosts_from_tags
|
||||
if accessory_config.key?("tags")
|
||||
accessory_config["tags"].flat_map { |tag| config.tag(tag)&.hosts }
|
||||
end
|
||||
end
|
||||
|
||||
def network
|
||||
accessory_config["network"] || DEFAULT_NETWORK
|
||||
end
|
||||
|
||||
@@ -46,13 +46,15 @@ accessories:
|
||||
|
||||
# Accessory hosts
|
||||
#
|
||||
# Specify one of `host`, `hosts`, or `roles`:
|
||||
# Specify one of `host`, `hosts`, `roles`, or `tags`:
|
||||
host: mysql-db1
|
||||
hosts:
|
||||
- mysql-db1
|
||||
- mysql-db2
|
||||
roles:
|
||||
- mysql
|
||||
tags:
|
||||
- writer
|
||||
|
||||
# Custom command
|
||||
#
|
||||
|
||||
@@ -2,8 +2,8 @@ class Kamal::Configuration::Validator::Accessory < Kamal::Configuration::Validat
|
||||
def validate!
|
||||
super
|
||||
|
||||
if (config.keys & [ "host", "hosts", "roles" ]).size != 1
|
||||
error "specify one of `host`, `hosts` or `roles`"
|
||||
if (config.keys & [ "host", "hosts", "roles", "tags" ]).size != 1
|
||||
error "specify one of `host`, `hosts`, `roles` or `tags`"
|
||||
end
|
||||
|
||||
validate_docker_options!(config["options"])
|
||||
|
||||
Reference in New Issue
Block a user