Class: RunLogs

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/terraform/gcp/linux/log_service/log_service.rb

Overview

Implements a simple HTTP server that serves the various run logs

Instance Method Summary collapse

Instance Method Details

#do_GET(_request, response) ⇒ Object

rubocop:disable Naming/MethodName



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/terraform/gcp/linux/log_service/log_service.rb', line 10

def do_GET(_request, response)
  run_logs = {}
  p_logs = read_log_file('/opt/cem_acpt/provision_apply.log')
  i_logs = read_log_file('/opt/cem_acpt/idempotent_apply.log')
  n_logs = read_log_file('/opt/cem_acpt/noop_apply.log')
  run_logs['provision'] = p_logs unless p_logs.empty?
  run_logs['idempotent'] = i_logs unless i_logs.empty?
  run_logs['noop'] = n_logs unless n_logs.empty?
  response.status = run_logs.empty? ? 404 : 200
  response['Content-Type'] = 'application/json'
  response.body = run_logs.to_json
end