-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgithub.go
More file actions
46 lines (42 loc) · 1.23 KB
/
github.go
File metadata and controls
46 lines (42 loc) · 1.23 KB
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
40
41
42
43
44
45
46
package plugins
import (
"flag"
"fmt"
)
// GitHub returns an Integration configured for the GitHub API.
func GitHub(name, tokenRef, webhookSecretRef string) Integration {
return Integration{
Name: name,
Destination: "https://api.github.com",
InRateLimit: 100,
OutRateLimit: 100,
IncomingAuth: []AuthPluginConfig{{
Type: "github_signature",
Params: map[string]interface{}{
"secrets": []string{webhookSecretRef},
},
}},
OutgoingAuth: []AuthPluginConfig{{
Type: "token",
Params: map[string]interface{}{
"secrets": []string{tokenRef},
"header": "Authorization",
"prefix": "token ",
},
}},
}
}
func init() { Register("github", githubBuilder) }
func githubBuilder(args []string) (Integration, error) {
fs := flag.NewFlagSet("github", flag.ContinueOnError)
name := fs.String("name", "github", "integration name")
token := fs.String("token", "", "secret reference for API token")
secret := fs.String("webhook-secret", "", "secret reference for webhook secret")
if err := fs.Parse(args); err != nil {
return Integration{}, err
}
if *token == "" || *secret == "" {
return Integration{}, fmt.Errorf("-token and -webhook-secret are required")
}
return GitHub(*name, *token, *secret), nil
}