-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpagerduty.go
More file actions
39 lines (35 loc) · 994 Bytes
/
pagerduty.go
File metadata and controls
39 lines (35 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package plugins
import (
"flag"
"fmt"
)
// PagerDuty returns an Integration configured for the PagerDuty API.
func PagerDuty(name, tokenRef string) Integration {
return Integration{
Name: name,
Destination: "https://api.pagerduty.com",
InRateLimit: 100,
OutRateLimit: 100,
OutgoingAuth: []AuthPluginConfig{{
Type: "token",
Params: map[string]interface{}{
"secrets": []string{tokenRef},
"header": "Authorization",
"prefix": "Token token=",
},
}},
}
}
func init() { Register("pagerduty", pagerdutyBuilder) }
func pagerdutyBuilder(args []string) (Integration, error) {
fs := flag.NewFlagSet("pagerduty", flag.ContinueOnError)
name := fs.String("name", "pagerduty", "integration name")
token := fs.String("token", "", "secret reference for API token")
if err := fs.Parse(args); err != nil {
return Integration{}, err
}
if *token == "" {
return Integration{}, fmt.Errorf("-token is required")
}
return PagerDuty(*name, *token), nil
}