Module: Sinatra::PuppetWebhookRoutes::Module

Defined in:
lib/routes/module.rb

Overview

Registers a POST endpoint for the PuppetWebhook App

Class Method Summary collapse

Class Method Details

.registered(puppet_webhook) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/routes/module.rb', line 7

def self.registered(puppet_webhook)
  puppet_webhook.post '/module' do
    protected! if settings.protected
    request.body.rewind # in case someone has already read it

    # Short circuit if we're ignoring this event
    return 200 if ignore_event?

    # TODO: Move these two lines of code into the parser
    decoded = request.body.read
    verify_signature(settings.github_secret, decoded) if verify_signature?

    module_name = env['parsed_body'][:module_name]

    module_name = sanitize_input(module_name)
    LOGGER.info("Deploying module #{module_name}")
    Process.detach(fork { deploy_module(module_name) })
  end
end