forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
31 lines (26 loc) · 996 Bytes
/
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
package hooks
import (
"github.com/rancher/rancher/pkg/pipeline/hooks/drivers"
"github.com/rancher/types/config"
"net/http"
)
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("")
sourceCodeCredentialLister := Management.Project.SourceCodeCredentials("").Controller().Lister()
Drivers = map[string]Driver{}
Drivers[drivers.GithubWebhookHeader] = drivers.GithubDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
Drivers[drivers.GitlabWebhookHeader] = drivers.GitlabDriver{
PipelineLister: pipelineLister,
PipelineExecutions: pipelineExecutions,
SourceCodeCredentialLister: sourceCodeCredentialLister,
}
}