More natural api when you are just applying accessory to a single tag
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -53,8 +53,10 @@ accessories:
|
||||
- mysql-db2
|
||||
roles:
|
||||
- mysql
|
||||
tag: writer
|
||||
tags:
|
||||
- writer
|
||||
- reader
|
||||
|
||||
# Custom command
|
||||
#
|
||||
|
||||
@@ -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"])
|
||||
|
||||
@@ -73,7 +73,11 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
},
|
||||
"proxy" => {
|
||||
"image" => "proxy:latest",
|
||||
"tags" => [ "writer" ]
|
||||
"tags" => [ "writer", "reader" ]
|
||||
},
|
||||
"logger" => {
|
||||
"image" => "logger:latest",
|
||||
"tag" => "writer"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +115,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
assert_equal [ "1.1.1.5" ], @config.accessory(:mysql).hosts
|
||||
assert_equal [ "1.1.1.6", "1.1.1.7" ], @config.accessory(:redis).hosts
|
||||
assert_equal [ "1.1.1.1", "1.1.1.2" ], @config.accessory(:monitoring).hosts
|
||||
assert_equal [ "1.1.1.1", "1.1.1.3" ], @config.accessory(:proxy).hosts
|
||||
assert_equal [ "1.1.1.1", "1.1.1.3", "1.1.1.2" ], @config.accessory(:proxy).hosts
|
||||
end
|
||||
|
||||
test "missing host" do
|
||||
@@ -129,7 +133,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
exception = assert_raises(Kamal::ConfigurationError) do
|
||||
Kamal::Configuration.new(@deploy)
|
||||
end
|
||||
assert_equal "accessories/mysql: specify one of `host`, `hosts`, `roles` or `tags`", exception.message
|
||||
assert_equal "accessories/mysql: specify one of `host`, `hosts`, `roles`, `tag` or `tags`", exception.message
|
||||
end
|
||||
|
||||
test "all hosts" do
|
||||
|
||||
Reference in New Issue
Block a user