Check for label presence in the validation, don't validate labels on simple role setup

This commit is contained in:
Nick Hammond
2025-06-09 19:36:27 -07:00
parent 1d88281fee
commit b164d50ff1
3 changed files with 4 additions and 2 deletions

View File

@@ -170,6 +170,8 @@ class Kamal::Configuration::Validator
end end
def validate_labels!(labels) def validate_labels!(labels)
return true if labels.blank?
with_context("labels") do with_context("labels") do
labels.each do |key, _| labels.each do |key, _|
with_context(key) do with_context(key) do

View File

@@ -6,7 +6,7 @@ class Kamal::Configuration::Validator::Accessory < Kamal::Configuration::Validat
error "specify one of `host`, `hosts`, `role`, `roles`, `tag` or `tags`" error "specify one of `host`, `hosts`, `role`, `roles`, `tag` or `tags`"
end end
validate_labels!(config["labels"]) if config.key?("labels") validate_labels!(config["labels"])
validate_docker_options!(config["options"]) validate_docker_options!(config["options"])
end end

View File

@@ -2,12 +2,12 @@ class Kamal::Configuration::Validator::Role < Kamal::Configuration::Validator
def validate! def validate!
validate_type! config, Array, Hash validate_type! config, Array, Hash
validate_labels!(config["labels"]) if config.key?("labels")
if config.is_a?(Array) if config.is_a?(Array)
validate_servers!(config) validate_servers!(config)
else else
super super
validate_labels!(config["labels"])
validate_docker_options!(config["options"]) validate_docker_options!(config["options"])
end end
end end