forked from harness/gitness
/
register.go
64 lines (58 loc) · 1.85 KB
/
register.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package github
import (
"github.com/drone/config"
"github.com/drone/drone/plugin/remote"
)
var (
// GitHub cloud configuration details
githubClient = config.String("github-client", "")
githubSecret = config.String("github-secret", "")
githubOrgs = config.Strings("github-orgs")
githubOpen = config.Bool("github-open", false)
// GitHub Enterprise configuration details
githubEnterpriseURL = config.String("github-enterprise-url", "")
githubEnterpriseAPI = config.String("github-enterprise-api", "")
githubEnterpriseClient = config.String("github-enterprise-client", "")
githubEnterpriseSecret = config.String("github-enterprise-secret", "")
githubEnterprisePrivate = config.Bool("github-enterprise-private-mode", true)
githubEnterpriseSkipVerify = config.Bool("github-enterprise-skip-verify", false)
githubEnterpriseOrgs = config.Strings("github-enterprise-orgs")
githubEnterpriseOpen = config.Bool("github-enterprise-open", false)
)
// Registers the GitHub plugins using the default
// settings from the config file or environment
// variables.
func Register() {
registerGitHub()
registerGitHubEnterprise()
}
// registers the GitHub (github.com) plugin
func registerGitHub() {
if len(*githubClient) == 0 || len(*githubSecret) == 0 {
return
}
remote.Register(
NewDefault(*githubClient, *githubSecret, *githubOrgs, *githubOpen),
)
}
// registers the GitHub Enterprise plugin
func registerGitHubEnterprise() {
if len(*githubEnterpriseURL) == 0 ||
len(*githubEnterpriseAPI) == 0 ||
len(*githubEnterpriseClient) == 0 ||
len(*githubEnterpriseSecret) == 0 {
return
}
remote.Register(
New(
*githubEnterpriseURL,
*githubEnterpriseAPI,
*githubEnterpriseClient,
*githubEnterpriseSecret,
*githubEnterprisePrivate,
*githubEnterpriseSkipVerify,
*githubEnterpriseOrgs,
*githubEnterpriseOpen,
),
)
}