From c69d6e156936219a6231c908788912f68d5aa980 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 22 Jan 2023 21:58:30 +0100 Subject: [PATCH] Fix volume args --- lib/mrsk/configuration.rb | 6 +++--- test/commands/app_test.rb | 2 +- test/configuration_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mrsk/configuration.rb b/lib/mrsk/configuration.rb index b44d6988..dd6d6cb5 100644 --- a/lib/mrsk/configuration.rb +++ b/lib/mrsk/configuration.rb @@ -7,7 +7,7 @@ require "mrsk/utils" class Mrsk::Configuration delegate :service, :image, :servers, :env, :labels, :registry, :builder, to: :raw_config, allow_nil: true - delegate :argumentize_env_with_secrets, to: Mrsk::Utils + delegate :argumentize, :argumentize_env_with_secrets, to: Mrsk::Utils attr_accessor :raw_config @@ -99,8 +99,8 @@ class Mrsk::Configuration end def volume_args - if config.volumes.present? - config.volumes.map { |volume| "--volume #{volume}" } + if raw_config.volumes.present? + argumentize "--volume", raw_config.volumes else [] end diff --git a/test/commands/app_test.rb b/test/commands/app_test.rb index 15f72d66..75be5aa6 100644 --- a/test/commands/app_test.rb +++ b/test/commands/app_test.rb @@ -19,7 +19,7 @@ class CommandsAppTest < ActiveSupport::TestCase @config[:volumes] = ["/local/path:/container/path" ] assert_equal \ - [:docker, :run, "-d", "--restart unless-stopped", "--name", "app-missing", "-e", "RAILS_MASTER_KEY=456", "--volume /local/path:/container/path", "--label", "service=app", "--label", "role=web", "--label", "traefik.http.routers.app.rule='PathPrefix(`/`)'", "--label", "traefik.http.services.app.loadbalancer.healthcheck.path=/up", "--label", "traefik.http.services.app.loadbalancer.healthcheck.interval=1s", "--label", "traefik.http.middlewares.app.retry.attempts=3", "--label", "traefik.http.middlewares.app.retry.initialinterval=500ms", "dhh/app:missing"], @app.run + [:docker, :run, "-d", "--restart unless-stopped", "--name", "app-missing", "-e", "RAILS_MASTER_KEY=456", "--volume", "/local/path:/container/path", "--label", "service=app", "--label", "role=web", "--label", "traefik.http.routers.app.rule='PathPrefix(`/`)'", "--label", "traefik.http.services.app.loadbalancer.healthcheck.path=/up", "--label", "traefik.http.services.app.loadbalancer.healthcheck.interval=1s", "--label", "traefik.http.middlewares.app.retry.attempts=3", "--label", "traefik.http.middlewares.app.retry.initialinterval=500ms", "dhh/app:missing"], @app.run end test "run with" do diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 3870e460..09e64fa2 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -135,7 +135,7 @@ class ConfigurationTest < ActiveSupport::TestCase end test "volume_args" do - assert_equal ["--volume /local/path:/container/path"], @config.volume_args + assert_equal ["--volume", "/local/path:/container/path"], @config.volume_args end test "erb evaluation of yml config" do @@ -162,6 +162,6 @@ class ConfigurationTest < ActiveSupport::TestCase end test "to_h" do - assert_equal({ :roles=>["web"], :hosts=>["1.1.1.1", "1.1.1.2"], :primary_host=>"1.1.1.1", :version=>"missing", :repository=>"dhh/app", :absolute_image=>"dhh/app:missing", :service_with_version=>"app-missing", :env_args=>["-e", "REDIS_URL=redis://x/y"], :ssh_options=>{:user=>"root", :auth_methods=>["publickey"]}, :volume_args=>["--volume /local/path:/container/path"] }, @config.to_h) + assert_equal({ :roles=>["web"], :hosts=>["1.1.1.1", "1.1.1.2"], :primary_host=>"1.1.1.1", :version=>"missing", :repository=>"dhh/app", :absolute_image=>"dhh/app:missing", :service_with_version=>"app-missing", :env_args=>["-e", "REDIS_URL=redis://x/y"], :ssh_options=>{:user=>"root", :auth_methods=>["publickey"]}, :volume_args=>["--volume", "/local/path:/container/path"] }, @config.to_h) end end