Validate that destination, role, and service are not set as labels on roles and accessories
This commit is contained in:
@@ -169,6 +169,16 @@ class Kamal::Configuration::Validator
|
||||
unknown_keys_error unknown_keys if unknown_keys.present?
|
||||
end
|
||||
|
||||
def validate_labels!(labels)
|
||||
with_context("labels") do
|
||||
labels.each do |key, _|
|
||||
with_context(key) do
|
||||
error "invalid label. destination, role, and service are reserved labels" if %w[destination role service].include?(key)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def validate_docker_options!(options)
|
||||
if options
|
||||
error "Cannot set restart policy in docker options, unless-stopped is required" if options["restart"]
|
||||
|
||||
@@ -6,6 +6,8 @@ class Kamal::Configuration::Validator::Accessory < Kamal::Configuration::Validat
|
||||
error "specify one of `host`, `hosts`, `role`, `roles`, `tag` or `tags`"
|
||||
end
|
||||
|
||||
validate_labels!(config["labels"]) if config.key?("labels")
|
||||
|
||||
validate_docker_options!(config["options"])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,8 @@ class Kamal::Configuration::Validator::Role < Kamal::Configuration::Validator
|
||||
def validate!
|
||||
validate_type! config, Array, Hash
|
||||
|
||||
validate_labels!(config["labels"]) if config.key?("labels")
|
||||
|
||||
if config.is_a?(Array)
|
||||
validate_servers!(config)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user