37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.go 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
phli 提交于 2018-09-19 16:48 . add bitbucket support in pipeline
package utils
import (
"fmt"
"github.com/rancher/rancher/pkg/ref"
"github.com/rancher/types/apis/project.cattle.io/v3"
)
const (
PipelineByProjectIndex = "pipeline.project.cattle.io/pipeline-by-project"
PipelineExecutionByClusterIndex = "pipeline.project.cattle.io/execution-by-cluster"
PipelineExecutionByProjectIndex = "pipeline.project.cattle.io/execution-by-project"
SourceCodeCredentialByProjectAndTypeIndex = "pipeline.project.cattle.io/credential-by-project-and-type"
SourceCodeRepositoryByCredentialIndex = "pipeline.project.cattle.io/repository-by-credential"
SourceCodeRepositoryByProjectAndTypeIndex = "pipeline.project.cattle.io/repository-by-project-and-type"
)
func PipelineByProjectName(obj interface{}) ([]string, error) {
pipeline, ok := obj.(*v3.Pipeline)
if !ok {
return []string{}, nil
}
return []string{pipeline.Spec.ProjectName}, nil
}
func PipelineExecutionByProjectName(obj interface{}) ([]string, error) {
execution, ok := obj.(*v3.PipelineExecution)
if !ok {
return []string{}, nil
}
return []string{execution.Spec.ProjectName}, nil
}
func PipelineExecutionByClusterName(obj interface{}) ([]string, error) {
execution, ok := obj.(*v3.PipelineExecution)
if !ok {
return []string{}, nil
}
cluster, _ := ref.Parse(execution.Spec.ProjectName)
return []string{cluster}, nil
}
func SourceCodeCredentialByProjectNameAndType(obj interface{}) ([]string, error) {
credential, ok := obj.(*v3.SourceCodeCredential)
if !ok {
return []string{}, nil
}
key := ProjectNameAndSourceCodeTypeKey(credential.Spec.ProjectName, credential.Spec.SourceCodeType)
return []string{key}, nil
}
func SourceCodeRepositoryByProjectNameAndType(obj interface{}) ([]string, error) {
repository, ok := obj.(*v3.SourceCodeRepository)
if !ok {
return []string{}, nil
}
key := ProjectNameAndSourceCodeTypeKey(repository.Spec.ProjectName, repository.Spec.SourceCodeType)
return []string{key}, nil
}
func SourceCodeRepositoryByCredentialName(obj interface{}) ([]string, error) {
repository, ok := obj.(*v3.SourceCodeRepository)
if !ok {
return []string{}, nil
}
return []string{repository.Spec.SourceCodeCredentialName}, nil
}
func ProjectNameAndSourceCodeTypeKey(projectName, souceCodeType string) string {
return fmt.Sprintf("%s.%s", projectName, souceCodeType)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.3-rc3

搜索帮助

0d507c66 1850385 C8b1a773 1850385