From 267b52643893ae644f30f09469b283ecb187f3c5 Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Mon, 16 Sep 2024 20:45:09 +0100 Subject: [PATCH] Switch proxy/hosts to proxy/host The proxy only supports a single host per app for nowm so make the config match that. --- lib/kamal/configuration/docs/proxy.yml | 10 ++++------ lib/kamal/configuration/proxy.rb | 2 +- lib/kamal/configuration/validator/proxy.rb | 2 +- test/configuration/proxy_test.rb | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index 0ca6befd9..e754eb36d 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -7,16 +7,14 @@ # run on the same proxy. proxy: - # Hosts + # Host # - # These are the hosts that will be used to serve the app. If you deploy more - # than one application to a single host, the proxy will route requests based - # these 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 that do have a host set. - hosts: - - foo.example.com + host: foo.example.com # App port # diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index a3161e1b2..2671b4c84 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -37,7 +37,7 @@ def ssl? def deploy_options { - host: proxy_config.fetch("hosts", []).first, + host: proxy_config["host"], tls: proxy_config["ssl"], "deploy-timeout": proxy_config["deploy_timeout"], "drain-timeout": proxy_config["drain_timeout"], diff --git a/lib/kamal/configuration/validator/proxy.rb b/lib/kamal/configuration/validator/proxy.rb index 2b0555706..a4ee19bf5 100644 --- a/lib/kamal/configuration/validator/proxy.rb +++ b/lib/kamal/configuration/validator/proxy.rb @@ -2,7 +2,7 @@ class Kamal::Configuration::Validator::Proxy < Kamal::Configuration::Validator def validate! super - if config["hosts"].blank? && config["ssl"] + if config["host"].blank? && config["ssl"] error "Must set a host to enable automatic SSL" end end diff --git a/test/configuration/proxy_test.rb b/test/configuration/proxy_test.rb index 6dac27ff3..3aa3f85e3 100644 --- a/test/configuration/proxy_test.rb +++ b/test/configuration/proxy_test.rb @@ -9,7 +9,7 @@ class ConfigurationEnvTest < ActiveSupport::TestCase end test "ssl with host" do - @deploy[:proxy] = { "ssl" => true, "hosts" => [ "example.com" ] } + @deploy[:proxy] = { "ssl" => true, "host" => "example.com" } assert_equal true, config.proxy.ssl? end