lita-pagerduty 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/.rspec +1 -0
- data/.rubocop.yml +0 -3
- data/.travis.yml +3 -3
- data/README.md +7 -0
- data/lib/lita-pagerduty.rb +20 -0
- data/lib/lita/handlers/pagerduty_ack.rb +4 -0
- data/lib/lita/handlers/pagerduty_note.rb +2 -0
- data/lib/lita/handlers/pagerduty_resolve.rb +4 -0
- data/lib/lita/handlers/pagerduty_utility.rb +4 -2
- data/lib/pagerduty_helper/incident.rb +4 -1
- data/lib/pagerduty_helper/regex.rb +1 -1
- data/lita-pagerduty.gemspec +1 -1
- data/locales/en.yml +2 -2
- data/spec/lita/handlers/pagerduty_incident_spec.rb +24 -3
- data/spec/spec_helper.rb +53 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f267ef87e565e1a057e419594aac1c2355b4b3b6
|
4
|
+
data.tar.gz: 2f1f47d4b76d1cb0343f52608b5bedf2f8e2ee4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d87edef11c6072ade59a61aba8b89f2324b54943638769d4c378d378f6a9157217c28810c17dc790093ba55e95b8689e64c1f1661cd1f3b26025f90ca5c5c4da
|
7
|
+
data.tar.gz: 9a81f446e593fc25bd7928ed89b7c2b2728ead01c84b24af402741142d1e15f0d276e29a44733740ce979dda4d7aa38689a3d54e65c2340b24710e41412300e5
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --profile 5
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -58,6 +58,13 @@ pager resolve mine - Resolve all triggered incidents assigned to
|
|
58
58
|
pager resolve <incident ID> - Resolve a specific incident
|
59
59
|
```
|
60
60
|
|
61
|
+
### Schedules
|
62
|
+
|
63
|
+
```
|
64
|
+
pager oncall - List available schedules
|
65
|
+
pager oncall <schedule> - Show who is on call for the given schedule
|
66
|
+
```
|
67
|
+
|
61
68
|
### Misc
|
62
69
|
|
63
70
|
```
|
data/lib/lita-pagerduty.rb
CHANGED
@@ -15,3 +15,23 @@ require 'lita/handlers/pagerduty_incident'
|
|
15
15
|
require 'lita/handlers/pagerduty_note'
|
16
16
|
require 'lita/handlers/pagerduty_resolve'
|
17
17
|
require 'lita/handlers/pagerduty_utility'
|
18
|
+
|
19
|
+
Lita::Handlers::PagerdutyAck.template_root File.expand_path(
|
20
|
+
File.join('..', '..', 'templates'), __FILE__
|
21
|
+
)
|
22
|
+
|
23
|
+
Lita::Handlers::PagerdutyIncident.template_root File.expand_path(
|
24
|
+
File.join('..', '..', 'templates'), __FILE__
|
25
|
+
)
|
26
|
+
|
27
|
+
Lita::Handlers::PagerdutyNote.template_root File.expand_path(
|
28
|
+
File.join('..', '..', 'templates'), __FILE__
|
29
|
+
)
|
30
|
+
|
31
|
+
Lita::Handlers::PagerdutyResolve.template_root File.expand_path(
|
32
|
+
File.join('..', '..', 'templates'), __FILE__
|
33
|
+
)
|
34
|
+
|
35
|
+
Lita::Handlers::PagerdutyUtility.template_root File.expand_path(
|
36
|
+
File.join('..', '..', 'templates'), __FILE__
|
37
|
+
)
|
@@ -37,6 +37,7 @@ module Lita
|
|
37
37
|
}
|
38
38
|
)
|
39
39
|
|
40
|
+
# rubocop:disable Metrics/AbcSize
|
40
41
|
def ack_all(response)
|
41
42
|
incidents = fetch_all_incidents
|
42
43
|
return response.reply(t('incident.none')) unless incidents.count > 0
|
@@ -47,7 +48,9 @@ module Lita
|
|
47
48
|
response.reply(t('all.acknowledged', list: completed.join(', ')))
|
48
49
|
end
|
49
50
|
end
|
51
|
+
# rubocop:enable Metrics/AbcSize
|
50
52
|
|
53
|
+
# rubocop:disable Metrics/AbcSize
|
51
54
|
def ack_mine(response)
|
52
55
|
email = fetch_user(response.user)
|
53
56
|
return response.reply(t('identify.missing')) unless email
|
@@ -60,6 +63,7 @@ module Lita
|
|
60
63
|
response.reply(t('all.acknowledged', list: completed.join(', ')))
|
61
64
|
end
|
62
65
|
end
|
66
|
+
# rubocop:enable Metrics/AbcSize
|
63
67
|
|
64
68
|
def ack(response)
|
65
69
|
incident_id = response.match_data['incident_id']
|
@@ -28,6 +28,7 @@ module Lita
|
|
28
28
|
}
|
29
29
|
)
|
30
30
|
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
31
32
|
def notes(response)
|
32
33
|
incident_id = response.match_data['incident_id']
|
33
34
|
incident = fetch_incident(incident_id)
|
@@ -37,6 +38,7 @@ module Lita
|
|
37
38
|
response.reply(format_note(incident, note))
|
38
39
|
end
|
39
40
|
end
|
41
|
+
# rubocop:enable Metrics/AbcSize
|
40
42
|
|
41
43
|
def note(response)
|
42
44
|
response.reply(t('error.not_implemented'))
|
@@ -37,6 +37,7 @@ module Lita
|
|
37
37
|
}
|
38
38
|
)
|
39
39
|
|
40
|
+
# rubocop:disable Metrics/AbcSize
|
40
41
|
def resolve_all(response)
|
41
42
|
incidents = fetch_all_incidents
|
42
43
|
return response.reply(t('incident.none')) unless incidents.count > 0
|
@@ -47,7 +48,9 @@ module Lita
|
|
47
48
|
response.reply(t('all.resolved', list: completed.join(',')))
|
48
49
|
end
|
49
50
|
end
|
51
|
+
# rubocop:enable Metrics/AbcSize
|
50
52
|
|
53
|
+
# rubocop:disable Metrics/AbcSize
|
51
54
|
def resolve_mine(response)
|
52
55
|
email = fetch_user(response.user)
|
53
56
|
return response.reply(t('identify.missing')) unless email
|
@@ -60,6 +63,7 @@ module Lita
|
|
60
63
|
response.reply(t('all.resolved', list: completed.join(',')))
|
61
64
|
end
|
62
65
|
end
|
66
|
+
# rubocop:enable Metrics/AbcSize
|
63
67
|
|
64
68
|
def resolve(response)
|
65
69
|
incident_id = response.match_data['incident_id']
|
@@ -54,16 +54,17 @@ module Lita
|
|
54
54
|
def on_call_list(response)
|
55
55
|
schedules = pd_client.get_schedules.schedules
|
56
56
|
if schedules.any?
|
57
|
-
schedule_list = schedules.map(&:name).join(
|
57
|
+
schedule_list = schedules.map(&:name).join("\n")
|
58
58
|
response.reply(t('on_call_list.response', schedules: schedule_list))
|
59
59
|
else
|
60
60
|
response.reply(t('on_call_list.no_schedules_found'))
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
# rubocop:disable Metrics/AbcSize
|
64
65
|
def on_call_lookup(response)
|
65
66
|
schedule_name = response.match_data[1].strip
|
66
|
-
schedule = pd_client.get_schedules.schedules.find { |s| s.
|
67
|
+
schedule = pd_client.get_schedules.schedules.find { |s| s.casecmp(schedule_name) == 0 }
|
67
68
|
|
68
69
|
unless schedule
|
69
70
|
return response.reply(t('on_call_lookup.no_matching_schedule', schedule_name: schedule_name))
|
@@ -75,6 +76,7 @@ module Lita
|
|
75
76
|
response.reply(t('on_call_lookup.no_one_on_call', schedule_name: schedule_name))
|
76
77
|
end
|
77
78
|
end
|
79
|
+
# rubocop:enable Metrics/AbcSize
|
78
80
|
|
79
81
|
def identify(response)
|
80
82
|
email = response.match_data['email']
|
@@ -5,7 +5,8 @@ module PagerdutyHelper
|
|
5
5
|
def format_incident(incident)
|
6
6
|
t('incident.info', id: incident.id,
|
7
7
|
subject: incident.trigger_summary_data.subject,
|
8
|
-
|
8
|
+
url: incident.html_url,
|
9
|
+
assigned: incident.assigned_to_user.nil? ? 'none' : incident.assigned_to_user.email)
|
9
10
|
end
|
10
11
|
|
11
12
|
def resolve_incident(incident_id)
|
@@ -45,6 +46,7 @@ module PagerdutyHelper
|
|
45
46
|
client.get_incident(id: incident_id)
|
46
47
|
end
|
47
48
|
|
49
|
+
# rubocop:disable Metrics/AbcSize
|
48
50
|
def acknowledge_incident(incident_id)
|
49
51
|
incident = fetch_incident(incident_id)
|
50
52
|
return t('incident.not_found', id: incident_id) if incident == 'No results'
|
@@ -57,5 +59,6 @@ module PagerdutyHelper
|
|
57
59
|
t('incident.unable_to_acknowledge', id: incident_id)
|
58
60
|
end
|
59
61
|
end
|
62
|
+
# rubocop:enable Metrics/AbcSize
|
60
63
|
end
|
61
64
|
end
|
data/lita-pagerduty.gemspec
CHANGED
data/locales/en.yml
CHANGED
@@ -66,7 +66,7 @@ en:
|
|
66
66
|
resolved: "%{id}: Incident resolved"
|
67
67
|
unable_to_acknowledge: "%{id}: Unable to acknowledge incident"
|
68
68
|
unable_to_resolve: "%{id}: Unable to resolve incident"
|
69
|
-
info: "%{id}: \"%{subject}\", assigned to: %{assigned}"
|
69
|
+
info: "%{id}: \"%{subject}\", assigned to: %{assigned}, url: %{url}"
|
70
70
|
forget:
|
71
71
|
complete: Your email has now been forgotten.
|
72
72
|
unknown: No email on record for you.
|
@@ -76,7 +76,7 @@ en:
|
|
76
76
|
note:
|
77
77
|
show: "%{id}: %{content} (%{email})"
|
78
78
|
on_call_list:
|
79
|
-
response: "Available schedules
|
79
|
+
response: "Available schedules:\n%{schedules}"
|
80
80
|
no_schedules_found: "No schedules found"
|
81
81
|
on_call_lookup:
|
82
82
|
response: "%{name} (%{email}) is currently on call for %{schedule_name}"
|
@@ -15,7 +15,7 @@ describe Lita::Handlers::PagerdutyIncident, lita_handler: true do
|
|
15
15
|
expect(Pagerduty).to receive(:new) { incidents }
|
16
16
|
send_command('pager incidents all')
|
17
17
|
expect(replies.last).to eq('ABC789: "Still broke", assigned to: '\
|
18
|
-
'bar@example.com')
|
18
|
+
'bar@example.com, url: https://acme.pagerduty.com/incidents/ABC789')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -37,7 +37,7 @@ describe Lita::Handlers::PagerdutyIncident, lita_handler: true do
|
|
37
37
|
send_command('pager identify bar@example.com', as: bar)
|
38
38
|
send_command('pager incidents mine', as: bar)
|
39
39
|
expect(replies.last).to eq('ABC789: "Still broke", assigned to: ' \
|
40
|
-
'bar@example.com')
|
40
|
+
'bar@example.com, url: https://acme.pagerduty.com/incidents/ABC789')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -67,7 +67,8 @@ describe Lita::Handlers::PagerdutyIncident, lita_handler: true do
|
|
67
67
|
expect(Pagerduty).to receive(:new) { new_incident }
|
68
68
|
send_command('pager incident ABC123')
|
69
69
|
expect(replies.last).to eq('ABC123: "something broke", ' \
|
70
|
-
'assigned to: foo@example.com'
|
70
|
+
'assigned to: foo@example.com, ' \
|
71
|
+
'url: https://acme.pagerduty.com/incidents/ABC123')
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -78,5 +79,25 @@ describe Lita::Handlers::PagerdutyIncident, lita_handler: true do
|
|
78
79
|
expect(replies.last).to eq('ABC123: Incident not found')
|
79
80
|
end
|
80
81
|
end
|
82
|
+
|
83
|
+
describe 'when the incident id is longer than 6 characters' do
|
84
|
+
it 'shows the incident details' do
|
85
|
+
expect(Pagerduty).to receive(:new) { incident_with_long_id }
|
86
|
+
send_command('pager incident ABC123456789')
|
87
|
+
expect(replies.last).to eq('ABC123456789: "something broke", ' \
|
88
|
+
'assigned to: foo@example.com, ' \
|
89
|
+
'url: https://acme.pagerduty.com/incidents/ABC123456789')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'when the incident is not assigned to anyone' do
|
94
|
+
it 'shows incident details with none user' do
|
95
|
+
expect(Pagerduty).to receive(:new) { incident_without_assigned_user }
|
96
|
+
send_command('pager incident ABC456')
|
97
|
+
expect(replies.last).to eq('ABC456: "something broke", ' \
|
98
|
+
'assigned to: none, ' \
|
99
|
+
'url: https://acme.pagerduty.com/incidents/ABC456')
|
100
|
+
end
|
101
|
+
end
|
81
102
|
end
|
82
103
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
require 'coveralls'
|
3
|
-
SimpleCov.
|
3
|
+
SimpleCov.formatters = [
|
4
4
|
SimpleCov::Formatter::HTMLFormatter,
|
5
5
|
Coveralls::SimpleCov::Formatter
|
6
6
|
]
|
@@ -19,6 +19,21 @@ RSpec.configure do |config|
|
|
19
19
|
registry.register_handler(Lita::Handlers::PagerdutyResolve)
|
20
20
|
registry.register_handler(Lita::Handlers::PagerdutyUtility)
|
21
21
|
end
|
22
|
+
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
25
|
+
end
|
26
|
+
|
27
|
+
config.mock_with :rspec do |mocks|
|
28
|
+
mocks.verify_partial_doubles = true
|
29
|
+
end
|
30
|
+
|
31
|
+
config.filter_run :focus
|
32
|
+
config.run_all_when_everything_filtered = true
|
33
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
34
|
+
config.order = :random
|
35
|
+
|
36
|
+
Kernel.srand config.seed
|
22
37
|
end
|
23
38
|
|
24
39
|
RSpec.shared_context 'basic fixtures' do
|
@@ -46,12 +61,14 @@ RSpec.shared_context 'basic fixtures' do
|
|
46
61
|
double(
|
47
62
|
id: 'ABC123',
|
48
63
|
status: 'resolved',
|
64
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
49
65
|
trigger_summary_data: double(subject: 'something broke'),
|
50
66
|
assigned_to_user: double(email: 'foo@example.com')
|
51
67
|
),
|
52
68
|
double(
|
53
69
|
id: 'ABC789',
|
54
70
|
status: 'triggered',
|
71
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC789',
|
55
72
|
trigger_summary_data: double(subject: 'Still broke'),
|
56
73
|
assigned_to_user: double(email: 'bar@example.com')
|
57
74
|
)
|
@@ -61,6 +78,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
61
78
|
allow(client).to receive(:get_incident) do
|
62
79
|
double(
|
63
80
|
status: 'triggered',
|
81
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC789',
|
64
82
|
trigger_summary_data: double(subject: 'Still broke'),
|
65
83
|
assigned_to_user: double(email: 'bar@example.com'),
|
66
84
|
acknowledge: { 'id' => 'ABC789', 'status' => 'acknowledged' },
|
@@ -77,6 +95,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
77
95
|
double(
|
78
96
|
id: 'ABC123',
|
79
97
|
status: 'triggered',
|
98
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
80
99
|
trigger_summary_data: double(subject: 'something broke'),
|
81
100
|
assigned_to_user: double(email: 'foo@example.com'),
|
82
101
|
acknowledge: { 'id' => 'ABC123', 'status' => 'acknowledged' },
|
@@ -87,11 +106,26 @@ RSpec.shared_context 'basic fixtures' do
|
|
87
106
|
client
|
88
107
|
end
|
89
108
|
|
109
|
+
let(:incident_without_assigned_user) do
|
110
|
+
client = double
|
111
|
+
expect(client).to receive(:get_incident) do
|
112
|
+
double(
|
113
|
+
id: 'ABC456',
|
114
|
+
status: 'triggered',
|
115
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC456',
|
116
|
+
trigger_summary_data: double(subject: 'something broke'),
|
117
|
+
assigned_to_user: nil
|
118
|
+
)
|
119
|
+
end
|
120
|
+
client
|
121
|
+
end
|
122
|
+
|
90
123
|
let(:acknowledged_incident) do
|
91
124
|
client = double
|
92
125
|
expect(client).to receive(:get_incident) do
|
93
126
|
double(
|
94
127
|
status: 'acknowledged',
|
128
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
95
129
|
trigger_summary_data: double(subject: 'something broke'),
|
96
130
|
assigned_to_user: double(email: 'foo@example.com'),
|
97
131
|
acknowledge: { 'error' =>
|
@@ -109,6 +143,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
109
143
|
expect(client).to receive(:get_incident) do
|
110
144
|
double(
|
111
145
|
status: 'resolved',
|
146
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
112
147
|
trigger_summary_data: double(subject: 'something broke'),
|
113
148
|
assigned_to_user: double(email: 'foo@example.com'),
|
114
149
|
notes: double(notes: [])
|
@@ -122,6 +157,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
122
157
|
expect(client).to receive(:get_incident) do
|
123
158
|
double(
|
124
159
|
status: 'notresolved',
|
160
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
125
161
|
resolve: { 'id' => 'ABC123', 'status' => 'notresolved' }
|
126
162
|
)
|
127
163
|
end
|
@@ -133,6 +169,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
133
169
|
expect(client).to receive(:get_incident) do
|
134
170
|
double(
|
135
171
|
status: 'notacked',
|
172
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
136
173
|
acknowledge: { 'error' => {} },
|
137
174
|
resolve: { 'id' => 'ABC123', 'status' => 'notacked' }
|
138
175
|
)
|
@@ -146,6 +183,7 @@ RSpec.shared_context 'basic fixtures' do
|
|
146
183
|
double(
|
147
184
|
id: 'ABC123',
|
148
185
|
status: 'resolved',
|
186
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123',
|
149
187
|
trigger_summary_data: double(subject: 'something broke'),
|
150
188
|
assigned_to_user: double(email: 'foo@example.com'),
|
151
189
|
notes: double(
|
@@ -156,4 +194,18 @@ RSpec.shared_context 'basic fixtures' do
|
|
156
194
|
end
|
157
195
|
client
|
158
196
|
end
|
197
|
+
|
198
|
+
let(:incident_with_long_id) do
|
199
|
+
client = double
|
200
|
+
expect(client).to receive(:get_incident) do
|
201
|
+
double(
|
202
|
+
id: 'ABC123456789',
|
203
|
+
status: 'triggered',
|
204
|
+
html_url: 'https://acme.pagerduty.com/incidents/ABC123456789',
|
205
|
+
trigger_summary_data: double(subject: 'something broke'),
|
206
|
+
assigned_to_user: double(email: 'foo@example.com')
|
207
|
+
)
|
208
|
+
end
|
209
|
+
client
|
210
|
+
end
|
159
211
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-pagerduty
|
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
|
- Eric Sigler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
|
+
- ".rspec"
|
133
134
|
- ".rubocop.yml"
|
134
135
|
- ".travis.yml"
|
135
136
|
- CONTRIBUTING.md
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
version: '0'
|
176
177
|
requirements: []
|
177
178
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.4.5
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: A Lita handler to interact with PagerDuty
|