File tree Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 1
1
package notify
2
2
3
3
import (
4
+ "github.com/deng00/go-notify/pagerduty"
4
5
"github.com/deng00/go-notify/pushover"
5
6
"github.com/deng00/go-notify/slack"
6
7
)
7
8
8
9
type Platform string
9
10
10
11
const (
11
- PlatformSlack Platform = "slack"
12
- PlatformPushover = "pushover"
13
- PlatformDingDing = "dingding"
12
+ PlatformSlack Platform = "slack"
13
+ PlatformPushover = "pushover"
14
+ PlatformDingDing = "dingding"
15
+ Platformpagerduty = "pagerduty"
14
16
)
15
17
16
18
type Notify struct {
@@ -35,6 +37,8 @@ func (n *Notify) Send(msg string) error {
35
37
return n .sendPushOverNotify (msg )
36
38
case PlatformSlack :
37
39
return n .sendSlackNotify (msg )
40
+ case Platformpagerduty :
41
+ return n .sendPagerdutyNotify (msg )
38
42
default :
39
43
panic ("not supported notify platform" )
40
44
}
@@ -58,3 +62,11 @@ func (n *Notify) sendSlackNotify(msg string) error {
58
62
err := app .Send (msg )
59
63
return err
60
64
}
65
+
66
+ func (n * Notify ) sendPagerdutyNotify (msg string ) error {
67
+ app := pagerduty .New (pagerduty.Options {
68
+ Token : n .config .Token ,
69
+ })
70
+ err := app .Send (msg )
71
+ return err
72
+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ func TestNotify_Send(t *testing.T) {
35
35
}},
36
36
args {msg : "test case" },
37
37
},
38
+ {
39
+ "test pagerduty notify" ,
40
+ fields {config : & Config {
41
+ Platform : Platform ("pagerduty" ),
42
+ Token : os .Getenv ("PAGERDUTY_TOKEN" ),
43
+ }},
44
+ args {msg : "test pagerduty" },
45
+ },
38
46
}
39
47
for _ , tt := range tests {
40
48
t .Run (tt .name , func (t * testing.T ) {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments