From 9d08d00a0bccf7aacb514929ad53a4b11a944ae9 Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Thu, 26 Sep 2024 09:28:24 +0400 Subject: [PATCH 1/2] Reuse CONTAINER_NAME constant --- lib/kamal/configuration.rb | 2 +- lib/kamal/configuration/proxy.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index 09f1ed895..56e1e5254 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -266,7 +266,7 @@ def proxy_image end def proxy_container_name - "kamal-proxy" + proxy.container_name end def proxy_directory diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index 6232c3e03..929427010 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -55,6 +55,10 @@ def merge(other) self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config) end + def container_name + CONTAINER_NAME + end + private def seconds_duration(value) value ? "#{value}s" : nil From e23103a3659fb8d5d264e201d3e45b78d8fef4b3 Mon Sep 17 00:00:00 2001 From: Igor Alexandrov Date: Wed, 9 Oct 2024 13:01:05 +0400 Subject: [PATCH 2/2] Delegate instead of define new method --- lib/kamal/configuration.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index 56e1e5254..8f7a59b1c 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -12,6 +12,8 @@ class Kamal::Configuration attr_reader :destination, :raw_config, :secrets attr_reader :accessories, :aliases, :boot, :builder, :env, :logging, :proxy, :servers, :ssh, :sshkit, :registry + delegate :container_name, to: :proxy, prefix: true + include Validation PROXY_MINIMUM_VERSION = "v0.8.0" @@ -265,10 +267,6 @@ def proxy_image "basecamp/kamal-proxy:#{PROXY_MINIMUM_VERSION}" end - def proxy_container_name - proxy.container_name - end - def proxy_directory File.join run_directory, "proxy" end