@@ -18,10 +18,11 @@ import (
1818
1919// GitHub - plugin main structure
2020type GitHub struct {
21- Repositories []string `toml:"repositories"`
22- AccessToken string `toml:"access_token"`
23- HTTPTimeout internal.Duration `toml:"http_timeout"`
24- githubClient * github.Client
21+ Repositories []string `toml:"repositories"`
22+ AccessToken string `toml:"access_token"`
23+ EnterpriseBaseURL string `toml:"enterprise_base_url"`
24+ HTTPTimeout internal.Duration `toml:"http_timeout"`
25+ githubClient * github.Client
2526
2627 obfusticatedToken string
2728
@@ -36,6 +37,9 @@ const sampleConfig = `
3637
3738 ## Github API access token. Unauthenticated requests are limited to 60 per hour.
3839 # access_token = ""
40+
41+ ## Github API enterprise url. Github Enterprise accounts must specify their base url.
42+ # enterprise_base_url = ""
3943
4044 ## Timeout for HTTP requests.
4145 # http_timeout = "5s"
@@ -71,9 +75,16 @@ func (g *GitHub) createGitHubClient(ctx context.Context) (*github.Client, error)
7175
7276 g .obfusticatedToken = g .AccessToken [0 :4 ] + "..." + g .AccessToken [len (g .AccessToken )- 3 :]
7377
74- return github . NewClient (oauthClient ), nil
78+ return g . newGithubClient (oauthClient )
7579 }
7680
81+ return g .newGithubClient (httpClient )
82+ }
83+
84+ func (g * GitHub ) newGithubClient (httpClient * http.Client ) (* github.Client , error ) {
85+ if g .EnterpriseBaseURL != "" {
86+ return github .NewEnterpriseClient (g .EnterpriseBaseURL , "" , httpClient )
87+ }
7788 return github .NewClient (httpClient ), nil
7889}
7990
0 commit comments