From 2ef57e7f349317f0790bb4e7d6113dce2452f3ec Mon Sep 17 00:00:00 2001 From: Xieql Date: Tue, 9 Jan 2024 20:20:38 +0800 Subject: [PATCH] update Signed-off-by: Xieql --- .../pipeline/render/predefined_task.go | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/pkg/fleet-manager/pipeline/render/predefined_task.go b/pkg/fleet-manager/pipeline/render/predefined_task.go index 2eca96cd7..9cedf001e 100644 --- a/pkg/fleet-manager/pipeline/render/predefined_task.go +++ b/pkg/fleet-manager/pipeline/render/predefined_task.go @@ -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` @@ -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) @@ -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, }