-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
47 lines (41 loc) · 1.71 KB
/
driver.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
package hooks
import (
"net/http"
"github.com/rancher/rancher/pkg/pipeline/hooks/drivers"
"github.com/rancher/types/config"
)
var Drivers map[string]Driver
type Driver interface {
Execute(req *http.Request) (int, error)
}
func RegisterDrivers(Management *config.ScaledContext) {
pipelineLister := Management.Project.Pipelines("").Controller().Lister()
pipelineExecutions := Management.Project.PipelineExecutions("")
sourceCodeCredentials := Management.Project.SourceCodeCredentials("")
sourceCodeCredentialLister := Management.Project.SourceCodeCredentials("").Controller().Lister()
Drivers = map[string]Driver{}
Drivers[drivers.GithubWebhookHeader] = drivers.GithubDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentials: sourceCodeCredentials,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
Drivers[drivers.GitlabWebhookHeader] = drivers.GitlabDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentials: sourceCodeCredentials,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
Drivers[drivers.BitbucketCloudWebhookHeader] = drivers.BitbucketCloudDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentials: sourceCodeCredentials,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
Drivers[drivers.BitbucketServerWebhookHeader] = drivers.BitbucketServerDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentials: sourceCodeCredentials,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
}