Add global logging configuration

This commit is contained in:
Samuel Sieg
2023-03-19 09:21:08 +01:00
parent d167e48584
commit b5372988f7
11 changed files with 83 additions and 41 deletions

View File

@@ -9,7 +9,8 @@ class ConfigurationTest < ActiveSupport::TestCase
registry: { "username" => "dhh", "password" => "secret" },
env: { "REDIS_URL" => "redis://x/y" },
servers: [ "1.1.1.1", "1.1.1.2" ],
volumes: ["/local/path:/container/path"]
volumes: ["/local/path:/container/path"],
logging: { "driver" => "json-file", "options" => { "max-size" => "10m" } }
}
@config = Mrsk::Configuration.new(@deploy)
@@ -157,6 +158,10 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal ["--volume", "/local/path:/container/path"], @config.volume_args
end
test "logging_args" do
assert_equal ["--log-driver", "json-file", "--log-opt", "max-size=\"10m\""], @config.logging_args
end
test "erb evaluation of yml config" do
config = Mrsk::Configuration.create_from Pathname.new(File.expand_path("fixtures/deploy.erb.yml", __dir__))
assert_equal "my-user", config.registry["username"]
@@ -181,6 +186,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"], :healthcheck=>{"path"=>"/up", "port"=>3000 }}, @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"], :logging=>{"driver"=>"json-file", "options"=>{"max-size"=>"10m"}}, :healthcheck=>{"path"=>"/up", "port"=>3000 }}, @config.to_h)
end
end