You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-12-17 21:57:29 +02:00
refactored how remotes work and how (some) config is loaded
This commit is contained in:
@@ -140,7 +140,7 @@ func (r *GitHub) GetRepos(user *model.User) ([]*model.Repo, error) {
|
||||
Owner: *item.Owner.Login,
|
||||
Name: *item.Name,
|
||||
Private: *item.Private,
|
||||
URL: *item.URL,
|
||||
URL: *item.HTMLURL,
|
||||
CloneURL: *item.GitURL,
|
||||
GitURL: *item.GitURL,
|
||||
SSHURL: *item.SSHURL,
|
||||
|
||||
@@ -1,41 +1,54 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/drone/config"
|
||||
"github.com/drone/drone/plugin/remote"
|
||||
)
|
||||
|
||||
func init() {
|
||||
init_github()
|
||||
init_github_enterprise()
|
||||
var (
|
||||
// GitHub cloud configuration details
|
||||
githubClient = config.String("github-client", "")
|
||||
githubSecret = config.String("github-secret", "")
|
||||
|
||||
// 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", "")
|
||||
)
|
||||
|
||||
// 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 init_github() {
|
||||
var cli = os.Getenv("GITHUB_CLIENT")
|
||||
var sec = os.Getenv("GITHUB_SECRET")
|
||||
if len(cli) == 0 ||
|
||||
len(sec) == 0 {
|
||||
func registerGitHub() {
|
||||
if len(*githubClient) == 0 || len(*githubSecret) == 0 {
|
||||
return
|
||||
}
|
||||
var github = NewDefault(cli, sec)
|
||||
remote.Register(github)
|
||||
remote.Register(
|
||||
NewDefault(*githubClient, *githubSecret),
|
||||
)
|
||||
}
|
||||
|
||||
// registers the GitHub Enterprise plugin
|
||||
func init_github_enterprise() {
|
||||
var url = os.Getenv("GITHUB_ENTERPRISE_URL")
|
||||
var api = os.Getenv("GITHUB_ENTERPRISE_API")
|
||||
var cli = os.Getenv("GITHUB_ENTERPRISE_CLIENT")
|
||||
var sec = os.Getenv("GITHUB_ENTERPRISE_SECRET")
|
||||
|
||||
if len(url) == 0 ||
|
||||
len(api) == 0 ||
|
||||
len(cli) == 0 ||
|
||||
len(sec) == 0 {
|
||||
func registerGitHubEnterprise() {
|
||||
if len(*githubEnterpriseURL) == 0 ||
|
||||
len(*githubEnterpriseAPI) == 0 ||
|
||||
len(*githubEnterpriseClient) == 0 ||
|
||||
len(*githubEnterpriseSecret) == 0 {
|
||||
return
|
||||
}
|
||||
var github = New(url, api, cli, sec)
|
||||
remote.Register(github)
|
||||
remote.Register(
|
||||
New(
|
||||
*githubEnterpriseURL,
|
||||
*githubEnterpriseAPI,
|
||||
*githubEnterpriseClient,
|
||||
*githubEnterpriseSecret,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user