Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #137 from dhollinger/module_endpoint_fix
Browse files Browse the repository at this point in the history
Fix a parser issue with the module endpoint
  • Loading branch information
dhollinger authored Jul 21, 2020
2 parents dc83c9b + b60616a commit fd2cb3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
13 changes: 0 additions & 13 deletions app/controllers/api/v1/r10k/environment_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ class EnvironmentController < ApplicationController

private

def headers
headers = {}
request.env.each do |k, v|
headers[k.to_s] = v.to_s if k =~ %r{^([A-Z]|_)+$}
end
headers
end

def req_body
request.body.rewind
request.body.read
end

def get_prefix(data)
case APP_CONFIG.prefix
when 'repo'
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/api/v1/r10k/module_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class ModuleController < ApplicationController
# POST: /module
post %r{\/(module|api\/v1\/r10k\/module)} do
protected! if APP_CONFIG.protected
request.body.rewind
data = PuppetWebhook::Parsers.new(request).params
data = PuppetWebhook::Parsers.new(headers, req_body).params

ModuleController.helpers R10kHelpers

Expand Down
13 changes: 13 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,17 @@ def slack_settings
{}
end
end

def headers
headers = {}
request.env.each do |k, v|
headers[k.to_s] = v.to_s if k =~ %r{^([A-Z]|_)+$}
end
headers
end

def req_body
request.body.rewind
request.body.read
end
end

0 comments on commit fd2cb3a

Please sign in to comment.