37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
setup.go 4.26 KB
一键复制 编辑 原始数据 按行查看 历史
phli 提交于 2018-06-26 16:36 . pipeline new ux
package providers
import (
"github.com/rancher/norman/types"
"github.com/rancher/rancher/pkg/pipeline/providers/github"
"github.com/rancher/rancher/pkg/pipeline/providers/gitlab"
"github.com/rancher/rancher/pkg/pipeline/remote/model"
"github.com/rancher/rancher/pkg/pipeline/utils"
"github.com/rancher/types/apis/project.cattle.io/v3/schema"
"github.com/rancher/types/client/project/v3"
"github.com/rancher/types/config"
"k8s.io/client-go/tools/cache"
)
var (
providers = make(map[string]SourceCodeProvider)
providersByType = make(map[string]SourceCodeProvider)
)
var sourceCodeProviderConfigTypes = []string{
client.GithubPipelineConfigType,
client.GitlabPipelineConfigType,
}
func SetupSourceCodeProviderConfig(management *config.ScaledContext, schemas *types.Schemas) {
configure(management)
providerBaseSchema := schemas.Schema(&schema.Version, client.SourceCodeProviderType)
setSourceCodeProviderStore(providerBaseSchema, management)
for _, scpSubtype := range sourceCodeProviderConfigTypes {
providersByType[scpSubtype].CustomizeSchemas(schemas)
}
}
func configure(management *config.ScaledContext) {
// Indexers for looking up resources by projectName, etc.
pipelineInformer := management.Project.Pipelines("").Controller().Informer()
pipelineIndexers := map[string]cache.IndexFunc{
utils.PipelineByProjectIndex: utils.PipelineByProjectName,
}
pipelineInformer.AddIndexers(pipelineIndexers)
executionInformer := management.Project.PipelineExecutions("").Controller().Informer()
executionIndexers := map[string]cache.IndexFunc{
utils.PipelineExecutionByProjectIndex: utils.PipelineExecutionByProjectName,
}
executionInformer.AddIndexers(executionIndexers)
sourceCodeCredentialInformer := management.Project.SourceCodeCredentials("").Controller().Informer()
sourceCodeCredentialIndexers := map[string]cache.IndexFunc{
utils.SourceCodeCredentialByProjectAndTypeIndex: utils.SourceCodeCredentialByProjectNameAndType,
}
sourceCodeCredentialInformer.AddIndexers(sourceCodeCredentialIndexers)
sourceCodeRepositoryInformer := management.Project.SourceCodeRepositories("").Controller().Informer()
sourceCodeRepositoryIndexers := map[string]cache.IndexFunc{
utils.SourceCodeRepositoryByCredentialIndex: utils.SourceCodeRepositoryByCredentialName,
utils.SourceCodeRepositoryByProjectAndTypeIndex: utils.SourceCodeRepositoryByProjectNameAndType,
}
sourceCodeRepositoryInformer.AddIndexers(sourceCodeRepositoryIndexers)
ghProvider := &github.GhProvider{
SourceCodeProviderConfigs: management.Project.SourceCodeProviderConfigs(""),
SourceCodeCredentialLister: management.Project.SourceCodeCredentials("").Controller().Lister(),
SourceCodeCredentials: management.Project.SourceCodeCredentials(""),
SourceCodeRepositories: management.Project.SourceCodeRepositories(""),
Pipelines: management.Project.Pipelines(""),
PipelineExecutions: management.Project.PipelineExecutions(""),
PipelineIndexer: pipelineInformer.GetIndexer(),
PipelineExecutionIndexer: executionInformer.GetIndexer(),
SourceCodeCredentialIndexer: sourceCodeCredentialInformer.GetIndexer(),
SourceCodeRepositoryIndexer: sourceCodeRepositoryInformer.GetIndexer(),
AuthConfigs: management.Management.AuthConfigs(""),
}
providers[model.GithubType] = ghProvider
providersByType[client.GithubPipelineConfigType] = ghProvider
glProvider := &gitlab.GlProvider{
SourceCodeProviderConfigs: management.Project.SourceCodeProviderConfigs(""),
SourceCodeCredentialLister: management.Project.SourceCodeCredentials("").Controller().Lister(),
SourceCodeCredentials: management.Project.SourceCodeCredentials(""),
SourceCodeRepositories: management.Project.SourceCodeRepositories(""),
Pipelines: management.Project.Pipelines(""),
PipelineExecutions: management.Project.PipelineExecutions(""),
PipelineIndexer: pipelineInformer.GetIndexer(),
PipelineExecutionIndexer: executionInformer.GetIndexer(),
SourceCodeCredentialIndexer: sourceCodeCredentialInformer.GetIndexer(),
SourceCodeRepositoryIndexer: sourceCodeRepositoryInformer.GetIndexer(),
AuthConfigs: management.Management.AuthConfigs(""),
}
providers[model.GitlabType] = glProvider
providersByType[client.GitlabPipelineConfigType] = glProvider
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.12-rc1

搜索帮助

0d507c66 1850385 C8b1a773 1850385