Class: Dash::Commands::Auditor

Inherits:
Base
  • Object
show all
Defined in:
lib/dash/commands/auditor.rb

Constant Summary

Constants inherited from Base

Base::DOCKER_HEALTH_STATUS_FORMAT, Base::EXEC_PROBE_FAILED, Base::NO_HEALTHCHECK, Base::READINESS_PROGRESS_PREFIX, Base::READY_STATUSES

Instance Attribute Summary collapse

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#confirmed_empty?, #container_id_for, #ensure_docker_installed, #ensure_run_directory, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh

Constructor Details

#initialize(config, **details) ⇒ Auditor

Returns a new instance of Auditor.



5
6
7
8
# File 'lib/dash/commands/auditor.rb', line 5

def initialize(config, **details)
  super(config)
  @details = details
end

Instance Attribute Details

#details ⇒ Object (readonly)

Returns the value of attribute details.



2
3
4
# File 'lib/dash/commands/auditor.rb', line 2

def details
  @details
end

Instance Method Details

#record(line, **details) ⇒ Object

Runs remotely



11
12
13
14
15
# File 'lib/dash/commands/auditor.rb', line 11

def record(line, **details)
  combine \
    ensure_run_directory,
    append([ :echo, escape_shell_value(audit_line(line, **details)) ], audit_log_file)
end

#record_then(line, *commands, **details) ⇒ Object

The audit line and the action it describes in one round trip, still in that order: the log is written first, and && means a failed write aborts the action exactly as a failed standalone audit would have.

Only ever fold in commands the caller would execute. A capture folded in here would come back with nothing to distinguish the audit's own output from the answer.



23
24
25
# File 'lib/dash/commands/auditor.rb', line 23

def record_then(line, *commands, **details)
  combine record(line, **details), *commands
end

#reveal ⇒ Object



27
28
29
# File 'lib/dash/commands/auditor.rb', line 27

def reveal
  [ :tail, "-n", 50, audit_log_file ]
end