Move audits back to run dir so they survive kamal remove
This commit is contained in:
@@ -9,7 +9,7 @@ class Kamal::Commands::Auditor < Kamal::Commands::Base
|
||||
# Runs remotely
|
||||
def record(line, **details)
|
||||
combine \
|
||||
[ :mkdir, "-p", config.service_directory ],
|
||||
[ :mkdir, "-p", config.run_directory ],
|
||||
append(
|
||||
[ :echo, audit_tags(**details).except(:version, :service_version, :service).to_s, line ],
|
||||
audit_log_file
|
||||
@@ -22,7 +22,9 @@ class Kamal::Commands::Auditor < Kamal::Commands::Base
|
||||
|
||||
private
|
||||
def audit_log_file
|
||||
File.join config.service_directory, "audit.log"
|
||||
file = [ config.service, config.destination, "audit.log" ].compact.join("-")
|
||||
|
||||
File.join(config.run_directory, file)
|
||||
end
|
||||
|
||||
def audit_tags(**details)
|
||||
|
||||
@@ -305,7 +305,7 @@ class CliMainTest < CliTestCase
|
||||
|
||||
test "audit" do
|
||||
run_command("audit").tap do |output|
|
||||
assert_match %r{tail -n 50 \.kamal/apps/app/audit.log on 1.1.1.1}, output
|
||||
assert_match %r{tail -n 50 \.kamal/app-audit.log on 1.1.1.1}, output
|
||||
assert_match /App Host: 1.1.1.1/, output
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,22 +18,22 @@ class CommandsAuditorTest < ActiveSupport::TestCase
|
||||
|
||||
test "record" do
|
||||
assert_equal [
|
||||
:mkdir, "-p", ".kamal/apps/app", "&&",
|
||||
:mkdir, "-p", ".kamal", "&&",
|
||||
:echo,
|
||||
"[#{@recorded_at}] [#{@performer}]",
|
||||
"app removed container",
|
||||
">>", ".kamal/apps/app/audit.log"
|
||||
">>", ".kamal/app-audit.log"
|
||||
], @auditor.record("app removed container")
|
||||
end
|
||||
|
||||
test "record with destination" do
|
||||
new_command(destination: "staging").tap do |auditor|
|
||||
assert_equal [
|
||||
:mkdir, "-p", ".kamal/apps/app-staging", "&&",
|
||||
:mkdir, "-p", ".kamal", "&&",
|
||||
:echo,
|
||||
"[#{@recorded_at}] [#{@performer}] [staging]",
|
||||
"app removed container",
|
||||
">>", ".kamal/apps/app-staging/audit.log"
|
||||
">>", ".kamal/app-staging-audit.log"
|
||||
], auditor.record("app removed container")
|
||||
end
|
||||
end
|
||||
@@ -41,22 +41,22 @@ class CommandsAuditorTest < ActiveSupport::TestCase
|
||||
test "record with command details" do
|
||||
new_command(role: "web").tap do |auditor|
|
||||
assert_equal [
|
||||
:mkdir, "-p", ".kamal/apps/app", "&&",
|
||||
:mkdir, "-p", ".kamal", "&&",
|
||||
:echo,
|
||||
"[#{@recorded_at}] [#{@performer}] [web]",
|
||||
"app removed container",
|
||||
">>", ".kamal/apps/app/audit.log"
|
||||
">>", ".kamal/app-audit.log"
|
||||
], auditor.record("app removed container")
|
||||
end
|
||||
end
|
||||
|
||||
test "record with arg details" do
|
||||
assert_equal [
|
||||
:mkdir, "-p", ".kamal/apps/app", "&&",
|
||||
:mkdir, "-p", ".kamal", "&&",
|
||||
:echo,
|
||||
"[#{@recorded_at}] [#{@performer}] [value]",
|
||||
"app removed container",
|
||||
">>", ".kamal/apps/app/audit.log"
|
||||
">>", ".kamal/app-audit.log"
|
||||
], @auditor.record("app removed container", detail: "value")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user