Skip to content

Commit

Permalink
Add NewWebhookService func
Browse files Browse the repository at this point in the history
Signed-off-by: jtcheng <[email protected]>
  • Loading branch information
jtcheng authored and danielfbm committed Jul 29, 2020
1 parent 689e730 commit 2f70877
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scm/driver/bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/jenkins-x/go-scm/scm"
)

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new Bitbucket API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
4 changes: 4 additions & 0 deletions scm/driver/gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
"github.com/jenkins-x/go-scm/scm"
)

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new Gitea API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
4 changes: 4 additions & 0 deletions scm/driver/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
// but will prevent an indefinite stall if GitHub never responds.
const maxRequestTime = 5 * time.Minute

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new GitHub API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
4 changes: 4 additions & 0 deletions scm/driver/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
"github.com/jenkins-x/go-scm/scm"
)

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new GitLab API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
4 changes: 4 additions & 0 deletions scm/driver/gogs/gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
"github.com/jenkins-x/go-scm/scm"
)

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new Gogs API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
4 changes: 4 additions & 0 deletions scm/driver/stash/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
// Reference API Documentation:
// https://docs.atlassian.com/bitbucket-server/rest/5.11.1/bitbucket-rest.html

func NewWebHookService() scm.WebhookService {
return &webhookService{nil}
}

// New returns a new Stash API client.
func New(uri string) (*scm.Client, error) {
base, err := url.Parse(uri)
Expand Down
27 changes: 27 additions & 0 deletions scm/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,30 @@ func Client(httpClient *http.Client) clientOptionFunc {
c.Client = httpClient
}
}

func NewWebHookService(driver string) (scm.WebhookService, error) {
if driver == "" {
driver = "github"
}
var service scm.WebhookService = nil
switch driver {
case "bitbucket", "bitbucketcloud":
service = bitbucket.NewWebHookService()
case "fake", "fakegit":
// TODO: support fake
case "gitea":
service = gitea.NewWebHookService()
case "github":
service = github.NewWebHookService()
case "gitlab":
service = gitlab.NewWebHookService()
case "gogs":
service = gogs.NewWebHookService()
case "stash", "bitbucketserver":
service = stash.NewWebHookService()
default:
return nil, fmt.Errorf("Unsupported GIT_KIND value: %s", driver)
}

return service, nil
}

0 comments on commit 2f70877

Please sign in to comment.