jackal-github 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/jackal-github/eventer.rb +51 -1
- data/lib/jackal-github/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc925771741af3b924cf5056e9067012df12180
|
4
|
+
data.tar.gz: cf4e8e925b5fee8f7f0e7b8e87b96e6dddbaa2bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c98ea2d30358dd5e145865437a718fcd11c50c48cff89dd4ed0d0bf6f773630d2d5c20ebe9d07768b3f7300876d868c0b2199a1f8c97c59442b3c9f23a6ae7
|
7
|
+
data.tar.gz: 762c40bc84dce3d4b1adb20d12ac073bc23e08adef47b5c43df5fe9a9bf39f6a1a37e57e42b3eb97151f026bf22280d9680f03bbf040d8a085c55defaaf61f39
|
data/CHANGELOG.md
CHANGED
@@ -22,10 +22,60 @@ module Jackal
|
|
22
22
|
failure_wrap(message) do |_|
|
23
23
|
content = format_payload(message)
|
24
24
|
payload = new_payload(name_for_payload(content), content)
|
25
|
-
|
25
|
+
filter(message, payload) do
|
26
|
+
job_completed(:github, payload, message)
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
31
|
+
# Apply filters to payload. If filters are enabled
|
32
|
+
# and no filter matches, discard payload
|
33
|
+
#
|
34
|
+
# @param message [Carnivore::Message]
|
35
|
+
# @param payload [Smash]
|
36
|
+
# @yield block to execute if payload is allowed
|
37
|
+
def filter(message, payload)
|
38
|
+
valid = true
|
39
|
+
a_events = allowed_events(payload)
|
40
|
+
r_events = restricted_events(payload)
|
41
|
+
if(a_events && !a_events.include?(payload.get(:data, :github, :event)))
|
42
|
+
valid = false
|
43
|
+
end
|
44
|
+
if(r_events && r_events.include?(payload.get(:data, :github, :event)))
|
45
|
+
valid = false
|
46
|
+
end
|
47
|
+
if(valid)
|
48
|
+
yield
|
49
|
+
else
|
50
|
+
warn "Message has been filtered and is restricted from entering pipeline (#{message})"
|
51
|
+
message.confirm!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Event types allowed to be dropped into pipeline
|
56
|
+
#
|
57
|
+
# @param payload [Smash]
|
58
|
+
# @return [Array, NilClass]
|
59
|
+
def allowed_events(payload)
|
60
|
+
a_events = config.fetch(:events, :allowed, [])
|
61
|
+
a_events += payload.fetch(:data, :github, :query, {}).map do |k,v|
|
62
|
+
k if v == 'enabled'
|
63
|
+
end.compact
|
64
|
+
a_events.empty? ? nil : a_events
|
65
|
+
end
|
66
|
+
|
67
|
+
# Event types restricted from being dropped into pipeline
|
68
|
+
#
|
69
|
+
# @param payload [Smash]
|
70
|
+
# @return [Array, NilClass]
|
71
|
+
def restricted_events(payload)
|
72
|
+
r_events = config.fetch(:events, :restricted, [])
|
73
|
+
r_events += payload.fetch(:data, :github, :query, {}).map do |k,v|
|
74
|
+
k if v == 'disabled'
|
75
|
+
end.compact
|
76
|
+
r_events.empty? ? nil : a_events
|
77
|
+
end
|
78
|
+
|
29
79
|
# Format the github event to store within the payload
|
30
80
|
#
|
31
81
|
# @param message [Carnivore::Message]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jackal
|