Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Xieql <xieqianglong@huawei.com>
  • Loading branch information
Xieql committed Jan 9, 2024
1 parent b58dc90 commit 2ef57e7
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions pkg/fleet-manager/pipeline/render/predefined_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,9 @@ import (
pipelineapi "kurator.dev/kurator/pkg/apis/pipeline/v1alpha1"
)

const (
// GitCloneTask is the predefined task template name of git clone task
GitCloneTask = "git-clone"
// GoTestTask is the predefined task template name of go test task
GoTestTask = "go-test"
// GoLintTask is the predefined task template name of golangci lint task
GoLintTask = "go-lint"
// BuildPushImage is the predefined task template name of task about building image and pushing it to image repo
BuildPushImage = "build-and-push-image"
)

type PredefinedTaskConfig struct {
PipelineName string
PipelineNamespace string
PipelineName string
Namespace string
// TemplateName is set by user in `Pipeline.Tasks[i].PredefinedTask.Name`
TemplateName string
// Params is set by user in `Pipeline.Tasks[i].PredefinedTask.Params`
Expand All @@ -53,11 +42,11 @@ func (cfg PredefinedTaskConfig) PredefinedTaskName() string {
// RenderPredefinedTaskWithPipeline takes a Pipeline object and generates YAML byte array configuration representing the PredefinedTask configuration.
func RenderPredefinedTaskWithPipeline(pipeline *pipelineapi.Pipeline, task *pipelineapi.PredefinedTask) ([]byte, error) {
cfg := PredefinedTaskConfig{
PipelineName: pipeline.Name,
PipelineNamespace: pipeline.Namespace,
TemplateName: string(task.Name),
Params: task.Params,
OwnerReference: GeneratePipelineOwnerRef(pipeline),
PipelineName: pipeline.Name,
Namespace: pipeline.Namespace,
TemplateName: string(task.Name),
Params: task.Params,
OwnerReference: GeneratePipelineOwnerRef(pipeline),
}

return RenderPredefinedTask(cfg)
Expand All @@ -74,12 +63,12 @@ func RenderPredefinedTask(cfg PredefinedTaskConfig) ([]byte, error) {
}

func generateTaskTemplateName(taskType string) string {
return "pipeline " + taskType + " task template"
return "pipeline-" + taskType + "-task template"
}

var predefinedTaskTemplates = map[string]string{
GitCloneTask: GitCloneTaskContent,
GoTestTask: GoTestTaskContent,
GoLintTask: GoLintTaskContent,
BuildPushImage: BuildPushImageContent,
string(pipelineapi.GitClone): GitCloneTaskContent,
string(pipelineapi.GoTest): GoTestTaskContent,
string(pipelineapi.GoLint): GoLintTaskContent,
string(pipelineapi.BuildPushImage): BuildPushImageContent,
}

0 comments on commit 2ef57e7

Please # to comment.