From 67ad7662ab9091523421eef0239a70b6bf76c112 Mon Sep 17 00:00:00 2001 From: Dmytro Shteflyuk Date: Sun, 29 Sep 2024 11:46:21 -0400 Subject: [PATCH] Simplified proxy hosts validation and documentation, similar to accessory config --- lib/kamal/configuration/docs/proxy.yml | 14 +++----------- lib/kamal/configuration/validator/proxy.rb | 4 ++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index 444e2da7..76ec3e41 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -17,24 +17,16 @@ # `proxy: true` or providing a proxy configuration. proxy: - # Host + # Hosts # # The hosts that will be used to serve the app. The proxy will only route requests # to this host to your app. # # If no hosts are set, then all requests will be forwarded, except for matching # requests for other apps deployed on that server that do have a host set. + # + # Specify one of `host` or `hosts`. host: foo.example.com - # If multiple hosts are needed, these can be specified by comma-separating the hosts. - host: foo.example.com,bar.example.com - - # Hosts - # - # The hosts that will be used to serve the app. The proxy will only route requests - # to these hosts to your app. - # - # If no hosts are set, then all requests will be forwarded, except for matching - # requests for other apps deployed on that server that do have a host set. hosts: - foo.example.com - bar.example.com diff --git a/lib/kamal/configuration/validator/proxy.rb b/lib/kamal/configuration/validator/proxy.rb index 3e2eda19..b9e11cd9 100644 --- a/lib/kamal/configuration/validator/proxy.rb +++ b/lib/kamal/configuration/validator/proxy.rb @@ -7,8 +7,8 @@ class Kamal::Configuration::Validator::Proxy < Kamal::Configuration::Validator error "Must set a host to enable automatic SSL" end - if config["host"].present? && config["hosts"].present? - error "Must use either 'host' or 'hosts', not both" + if (config.keys & [ "host", "hosts" ]).size > 1 + error "Specify one of 'host' or 'hosts', not both" end end end