puppet-community-rangefinder-webhook 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/rangefinder/webhook/version.rb +1 -1
- data/lib/rangefinder/webhook.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97d4e3e0e3376c9071f87ac1e3ea73922f0f69c671aec734b2760eb72af6e47d
|
4
|
+
data.tar.gz: 0f06f440ae68cd20937a1a4ea8df938d396ca1377458141c18dd107e5fac7470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c63f5214bde0ea420a1f6709714e163127db86a81c52cfb48ffb08d493ed4cb73503e1d5a44447a775818a10d7003f5c8d467c7cc4bc3d48f71af9c2d3e6c035
|
7
|
+
data.tar.gz: b160617aa6f2d0549879af64d03e6488458170410dbdc7317ccd2036c681c51b57124270c4f9ba8e9d8bc0a5e3a6680aec0a5c8dbe3a2184448e2503a3e9f5c0
|
data/CHANGELOG.md
CHANGED
data/lib/rangefinder/webhook.rb
CHANGED
@@ -31,6 +31,7 @@ class Rangefinder::Webhook < Sinatra::Base
|
|
31
31
|
rescue => e
|
32
32
|
$logger.error "There's a problem with your configuration file!"
|
33
33
|
$logger.error e.message
|
34
|
+
$logger.debug e.backtrace.join "\n"
|
34
35
|
exit 1
|
35
36
|
end
|
36
37
|
end
|
@@ -96,6 +97,9 @@ class Rangefinder::Webhook < Sinatra::Base
|
|
96
97
|
uri = files.shift[:blob_url] # this order is intentional, it keeps the two lists in sync
|
97
98
|
next if item.nil?
|
98
99
|
item[:fileuri] = uri
|
100
|
+
|
101
|
+
munge_repo_urls(item[:exact])
|
102
|
+
munge_repo_urls(item[:near])
|
99
103
|
end
|
100
104
|
@impact.compact!
|
101
105
|
|
@@ -104,6 +108,27 @@ class Rangefinder::Webhook < Sinatra::Base
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
111
|
+
def munge_repo_urls(mod)
|
112
|
+
mod.each do |item|
|
113
|
+
item[:repo] = canonicalize(item[:repo], item[:module])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def canonicalize(url, mod)
|
118
|
+
# do it like this instead of a regex because this should cover more git servers. (github, gitlab, bitbucket, etc)
|
119
|
+
if url.nil? or url.class != String
|
120
|
+
"https://forge.puppet.com/#{mod.sub('-', '/')}"
|
121
|
+
elsif url.start_with? 'git://'
|
122
|
+
url.sub(/^git/, 'https')
|
123
|
+
elsif url.start_with? 'git@'
|
124
|
+
url.sub(/^git@([^:]+):/, 'https://\1/')
|
125
|
+
elsif url !~ URI::regexp
|
126
|
+
"https://forge.puppet.com/#{mod.sub('-', '/')}"
|
127
|
+
else
|
128
|
+
url
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
107
132
|
# Saves the raw payload and converts the payload to JSON format
|
108
133
|
def get_payload_request(request)
|
109
134
|
# request.body is an IO or StringIO object
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-community-rangefinder-webhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Ford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|