To avoid polluting the default SSH directory with lots of Kamal config, we'll default to putting them in a `kamal` sub directory. But also make the directory configurable with the `run_directory` key, so for example you can set it as `/var/run/kamal/` The directory is created during bootstrap or before any command that will need to access a file.
31 lines
644 B
Ruby
31 lines
644 B
Ruby
class Kamal::Commands::Auditor < Kamal::Commands::Base
|
|
attr_reader :details
|
|
|
|
def initialize(config, **details)
|
|
super(config)
|
|
@details = details
|
|
end
|
|
|
|
# Runs remotely
|
|
def record(line, **details)
|
|
append \
|
|
[ :echo, audit_tags(**details).except(:version, :service_version).to_s, line ],
|
|
audit_log_file
|
|
end
|
|
|
|
def reveal
|
|
[ :tail, "-n", 50, audit_log_file ]
|
|
end
|
|
|
|
private
|
|
def audit_log_file
|
|
file = [ config.service, config.destination, "audit.log" ].compact.join("-")
|
|
|
|
"#{config.run_directory}/#{file}"
|
|
end
|
|
|
|
def audit_tags(**details)
|
|
tags(**self.details, **details)
|
|
end
|
|
end
|