Skip to content

Commit e3863e4

Browse files
committed
notifications: drop Icinga 2 specific event types
1 parent fe2ea7f commit e3863e4

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

notifications/event/type.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ const (
1717
TypeAcknowledgementCleared // acknowledgement-cleared
1818
TypeAcknowledgementSet // acknowledgement-set
1919
TypeCustom // custom
20-
TypeDowntimeEnd // downtime-end
21-
TypeDowntimeRemoved // downtime-removed
22-
TypeDowntimeStart // downtime-start
23-
TypeFlappingEnd // flapping-end
24-
TypeFlappingStart // flapping-start
2520
TypeIncidentAge // incident-age
2621
TypeMute // mute
2722
TypeState // state

notifications/event/type_string.go

Lines changed: 10 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notifications/event/type_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func TestType(t *testing.T) {
1818
{Name: "State", Expected: `"state"`, Data: TypeState, Error: nil},
1919
{Name: "Mute", Expected: `"mute"`, Data: TypeMute, Error: nil},
2020
{Name: "Unmute", Expected: `"unmute"`, Data: TypeUnmute, Error: nil},
21-
{Name: "DowntimeStart", Expected: `"downtime-start"`, Data: TypeDowntimeStart, Error: nil},
2221
}
2322

2423
for _, tt := range testdata {
@@ -37,7 +36,6 @@ func TestType(t *testing.T) {
3736
{Name: "State", Expected: TypeState, Data: `"state"`, Error: nil},
3837
{Name: "Mute", Expected: TypeMute, Data: `"mute"`, Error: nil},
3938
{Name: "Unmute", Expected: TypeUnmute, Data: `"unmute"`, Error: nil},
40-
{Name: "DowntimeStart", Expected: TypeDowntimeStart, Data: `"downtime-start"`, Error: nil},
4139
{Name: "Invalid", Expected: TypeUnknown, Data: `"invalid"`, Error: testutils.ErrorContains(`unknown type "invalid"`)},
4240
}
4341

@@ -57,7 +55,6 @@ func TestType(t *testing.T) {
5755
{Name: "State", Expected: TypeState, Data: `state`, Error: nil},
5856
{Name: "Mute", Expected: TypeMute, Data: `mute`, Error: nil},
5957
{Name: "Unmute", Expected: TypeUnmute, Data: `unmute`, Error: nil},
60-
{Name: "DowntimeStart", Expected: TypeDowntimeStart, Data: `downtime-start`, Error: nil},
6158
{Name: "Invalid", Expected: TypeUnknown, Data: `invalid`, Error: testutils.ErrorContains(`unknown type "invalid"`)},
6259
}
6360

@@ -77,7 +74,6 @@ func TestType(t *testing.T) {
7774
{Name: "State", Expected: `state`, Data: TypeState, Error: nil},
7875
{Name: "Mute", Expected: `mute`, Data: TypeMute, Error: nil},
7976
{Name: "Unmute", Expected: `unmute`, Data: TypeUnmute, Error: nil},
80-
{Name: "DowntimeStart", Expected: `downtime-start`, Data: TypeDowntimeStart, Error: nil},
8177
}
8278

8379
for _, tt := range testdata {

notifications/plugin/plugin.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,21 @@ func FormatSubject(req *NotificationRequest) string {
324324
switch req.Event.Type {
325325
case event.TypeState:
326326
return fmt.Sprintf("[#%d] %s %s is %s", req.Incident.Id, req.Event.Type, req.Object.Name, req.Incident.Severity)
327-
case event.TypeAcknowledgementCleared, event.TypeDowntimeRemoved:
327+
case event.TypeAcknowledgementCleared:
328328
if req.Incident != nil {
329329
return fmt.Sprintf("[#%d] %s from %s", req.Incident.Id, req.Event.Type, req.Object.Name)
330330
}
331331
return fmt.Sprintf("%s from %s", req.Event.Type, req.Object.Name)
332+
case event.TypeMute:
333+
if req.Incident != nil {
334+
return fmt.Sprintf("[#%d] %s is muted", req.Incident.Id, req.Object.Name)
335+
}
336+
return fmt.Sprintf("%s is muted", req.Object.Name)
337+
case event.TypeUnmute:
338+
if req.Incident != nil {
339+
return fmt.Sprintf("[#%d] %s is unmuted", req.Incident.Id, req.Object.Name)
340+
}
341+
return fmt.Sprintf("%s is unmuted", req.Object.Name)
332342
default:
333343
if req.Incident != nil {
334344
return fmt.Sprintf("[#%d] %s on %s", req.Incident.Id, req.Event.Type, req.Object.Name)

0 commit comments

Comments
 (0)