代码拉取完成,页面将自动刷新
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。