From feb0a01be36d9c2930ce232740657d25e4d6604f Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Fri, 31 Mar 2023 10:01:59 +0900 Subject: [PATCH 1/9] poc --- pkg/cmd/pipeline/start.go | 11 +++++++++++ pkg/pods/pod_template.go | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pkg/cmd/pipeline/start.go b/pkg/cmd/pipeline/start.go index 2052ae490..a6c853c26 100644 --- a/pkg/cmd/pipeline/start.go +++ b/pkg/cmd/pipeline/start.go @@ -85,6 +85,7 @@ type startOptions struct { UseParamDefaults bool TektonOptions flags.TektonOptions PodTemplate string + TaskRunSpec string SkipOptionalWorkspace bool } @@ -206,6 +207,7 @@ For passing the workspaces via flags: c.Flags().StringVarP(&opt.Filename, "filename", "f", "", "local or remote file name containing a Pipeline definition to start a PipelineRun") c.Flags().BoolVarP(&opt.UseParamDefaults, "use-param-defaults", "", false, "use default parameter values without prompting for input") c.Flags().StringVar(&opt.PodTemplate, "pod-template", "", "local or remote file containing a PodTemplate definition") + c.Flags().StringVar(&opt.TaskRunSpec, "task-run-spec", "", "local or remote file containing a TaskRunSpec definition") c.Flags().BoolVarP(&opt.SkipOptionalWorkspace, "skip-optional-workspace", "", false, "skips the prompt for optional workspaces") c.Flags().StringVarP(&opt.ServiceAccountName, "serviceaccount", "s", "", "pass the serviceaccount name") @@ -355,6 +357,15 @@ func (opt *startOptions) startPipeline(pipelineStart *v1beta1.Pipeline) error { pr.Spec.PodTemplate = &podTemplate } + taskRunSpecLocation := opt.TaskRunSpec + if taskRunSpecLocation != "" { + taskRunSpec, err := pods.ParseTaskRunSpec(cs.HTTPClient, taskRunSpecLocation, file.IsYamlFile(), fmt.Errorf("invalid file format for %s: .yaml or .yml file extension and format required", taskRunSpecLocation)) + if err != nil { + return err + } + pr.Spec.TaskRunSpecs = taskRunSpec + } + if opt.DryRun { format := strings.ToLower(opt.Output) if format == "name" { diff --git a/pkg/pods/pod_template.go b/pkg/pods/pod_template.go index 3cf04768e..fc219910d 100644 --- a/pkg/pods/pod_template.go +++ b/pkg/pods/pod_template.go @@ -19,6 +19,7 @@ import ( "github.com/tektoncd/cli/pkg/file" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "sigs.k8s.io/yaml" ) @@ -35,3 +36,19 @@ func ParsePodTemplate(httpClient http.Client, podTemplateLocation string, valida return podTemplate, nil } + +type TaskRunSpec = []v1beta1.PipelineTaskRunSpec + +func ParseTaskRunSpec(httpClient http.Client, taskRunSpecLocation string, validate file.TypeValidator, errorMsg error) (TaskRunSpec, error) { + taskRunSpec := TaskRunSpec{} + b, err := file.LoadFileContent(httpClient, taskRunSpecLocation, validate, errorMsg) + if err != nil { + return taskRunSpec, err + } + + if err := yaml.UnmarshalStrict(b, &taskRunSpec); err != nil { + return taskRunSpec, err + } + + return taskRunSpec, nil +} From bbe97402351d594c2654b278825d5cb801a1c650 Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Fri, 31 Mar 2023 15:48:04 +0900 Subject: [PATCH 2/9] make docs --- docs/cmd/tkn_pipeline_start.md | 1 + docs/man/man1/tkn-pipeline-start.1 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/cmd/tkn_pipeline_start.md b/docs/cmd/tkn_pipeline_start.md index 59024a7bf..681dd4a48 100644 --- a/docs/cmd/tkn_pipeline_start.md +++ b/docs/cmd/tkn_pipeline_start.md @@ -77,6 +77,7 @@ my-secret, my-empty-dir and my-volume-claim-template) -s, --serviceaccount string pass the serviceaccount name --showlog show logs right after starting the Pipeline --skip-optional-workspace skips the prompt for optional workspaces + --task-run-spec string local or remote file containing a TaskRunSpec definition --task-serviceaccount strings pass the service account corresponding to the task --tasks-timeout string timeout for Pipeline TaskRuns --use-param-defaults use default parameter values without prompting for input diff --git a/docs/man/man1/tkn-pipeline-start.1 b/docs/man/man1/tkn-pipeline-start.1 index 5633195b0..1eb23202c 100644 --- a/docs/man/man1/tkn-pipeline-start.1 +++ b/docs/man/man1/tkn-pipeline-start.1 @@ -83,6 +83,10 @@ Parameters, at least those that have no default value \fB\-\-skip\-optional\-workspace\fP[=false] skips the prompt for optional workspaces +.PP +\fB\-\-task\-run\-spec\fP="" + local or remote file containing a TaskRunSpec definition + .PP \fB\-\-task\-serviceaccount\fP=[] pass the service account corresponding to the task From 1e5023fe5a632e7580817373619cede226ac23ba Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Fri, 31 Mar 2023 18:59:23 +0900 Subject: [PATCH 3/9] Add unittests --- pkg/cmd/pipeline/start_test.go | 19 ++++++++++++ pkg/cmd/pipeline/start_v1_test.go | 18 +++++++++++ ...uteCommand-Dry_Run_with_TaskRunSpec.golden | 26 ++++++++++++++++ ...nd_v1beta1-Dry_Run_with_TaskRunSpec.golden | 30 +++++++++++++++++++ pkg/cmd/pipeline/testdata/taskrunspec.yaml | 6 ++++ 5 files changed, 99 insertions(+) create mode 100644 pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_TaskRunSpec.golden create mode 100644 pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand_v1beta1-Dry_Run_with_TaskRunSpec.golden create mode 100644 pkg/cmd/pipeline/testdata/taskrunspec.yaml diff --git a/pkg/cmd/pipeline/start_test.go b/pkg/cmd/pipeline/start_test.go index f731b60cf..28a313227 100644 --- a/pkg/cmd/pipeline/start_test.go +++ b/pkg/cmd/pipeline/start_test.go @@ -1010,6 +1010,25 @@ func TestPipelineStart_ExecuteCommand_v1beta1(t *testing.T) { wantError: false, goldenFile: true, }, + + { + name: "Dry Run with TaskRunSpec", + command: []string{ + "start", "test-pipeline", + "-s=svc1", + "-r=source=scaffold-git", + "-p=pipeline-param=value1", + "-p=rev-param=value2", + "-l=jemange=desfrites", + "-n", "ns", + "--dry-run", + "--task-run-spec", "./testdata/taskrunspec.yaml", + }, + namespace: "", + input: c2, + wantError: false, + goldenFile: true, + }, } for _, tp := range testParams { diff --git a/pkg/cmd/pipeline/start_v1_test.go b/pkg/cmd/pipeline/start_v1_test.go index 6eb48ffba..5ca8245f4 100644 --- a/pkg/cmd/pipeline/start_v1_test.go +++ b/pkg/cmd/pipeline/start_v1_test.go @@ -855,6 +855,24 @@ func TestPipelineStart_ExecuteCommand(t *testing.T) { wantError: false, goldenFile: true, }, + + { + name: "Dry Run with TaskRunSpec", + command: []string{ + "start", "test-pipeline", + "-s=svc1", + "-p=pipeline-param=value1", + "-p=rev-param=value2", + "-l=jemange=desfrites", + "-n", "ns", + "--dry-run", + "--task-run-spec", "./testdata/taskrunspec.yaml", + }, + namespace: "", + input: c2, + wantError: false, + goldenFile: true, + }, } for _, tp := range testParams { diff --git a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_TaskRunSpec.golden b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_TaskRunSpec.golden new file mode 100644 index 000000000..b7da2b30d --- /dev/null +++ b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand-Dry_Run_with_TaskRunSpec.golden @@ -0,0 +1,26 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + creationTimestamp: null + generateName: test-pipeline-run- + labels: + jemange: desfrites + namespace: ns +spec: + params: + - name: pipeline-param + value: value1 + - name: rev-param + value: value2 + pipelineRef: + name: test-pipeline + taskRunSpecs: + - pipelineTaskName: unit-test-task + podTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 + taskRunTemplate: + serviceAccountName: svc1 +status: {} diff --git a/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand_v1beta1-Dry_Run_with_TaskRunSpec.golden b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand_v1beta1-Dry_Run_with_TaskRunSpec.golden new file mode 100644 index 000000000..89d650fb2 --- /dev/null +++ b/pkg/cmd/pipeline/testdata/TestPipelineStart_ExecuteCommand_v1beta1-Dry_Run_with_TaskRunSpec.golden @@ -0,0 +1,30 @@ +Flag --resource has been deprecated, pipelineresources have been deprecated, this flag will be removed soon +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + creationTimestamp: null + generateName: test-pipeline-run- + labels: + jemange: desfrites + namespace: ns +spec: + params: + - name: pipeline-param + value: value1 + - name: rev-param + value: value2 + pipelineRef: + name: test-pipeline + resources: + - name: source + resourceRef: + name: scaffold-git + serviceAccountName: svc1 + taskRunSpecs: + - pipelineTaskName: unit-test-task + taskPodTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 +status: {} diff --git a/pkg/cmd/pipeline/testdata/taskrunspec.yaml b/pkg/cmd/pipeline/testdata/taskrunspec.yaml new file mode 100644 index 000000000..d9b0ca7d4 --- /dev/null +++ b/pkg/cmd/pipeline/testdata/taskrunspec.yaml @@ -0,0 +1,6 @@ +- pipelineTaskName: unit-test-task + taskPodTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 From aabe9e68d2834d25722f5a1a70d3a9a156b33018 Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Fri, 31 Mar 2023 19:19:19 +0900 Subject: [PATCH 4/9] add e2e test --- test/e2e/pipeline/pipeline_test.go | 17 +++++++++++++++++ test/resources/taskrunspec.yaml | 6 ++++++ 2 files changed, 23 insertions(+) create mode 100644 test/resources/taskrunspec.yaml diff --git a/test/e2e/pipeline/pipeline_test.go b/test/e2e/pipeline/pipeline_test.go index 802024aa6..d44ec72b1 100644 --- a/test/e2e/pipeline/pipeline_test.go +++ b/test/e2e/pipeline/pipeline_test.go @@ -305,6 +305,23 @@ Waiting for logs to be available... } }) + t.Run("Start PipelineRun with --task-run-spec", func(t *testing.T) { + tkn.MustSucceed(t, "pipeline", "start", tePipelineName, + "-p=filename=output", + "-w=name=shared-data,emptyDir=", + "--task-run-spec="+helper.GetResourcePath("/taskrunspec/taskrunspec.yaml"), + "--use-param-defaults", + "--showlog") + + time.Sleep(1 * time.Second) + + pipelineRunGeneratedName := builder.GetPipelineRunListWithName(c, tePipelineName, true).Items[0].Name + timeout := 5 * time.Minute + if err := wait.ForPipelineRunState(c, pipelineRunGeneratedName, timeout, wait.PipelineRunSucceed(pipelineRunGeneratedName), "PipelineRunSucceeded"); err != nil { + t.Errorf("Error waiting for PipelineRun to Succeed: %s", err) + } + }) + t.Run("Cancel finished PipelineRun with tkn pipelinerun cancel", func(t *testing.T) { // Get last PipelineRun for pipeline-with-workspace pipelineRunLast := builder.GetPipelineRunListWithName(c, tePipelineName, true).Items[0] diff --git a/test/resources/taskrunspec.yaml b/test/resources/taskrunspec.yaml new file mode 100644 index 000000000..9a6d14d1e --- /dev/null +++ b/test/resources/taskrunspec.yaml @@ -0,0 +1,6 @@ +- pipelineTaskName: first-create-file + taskPodTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 From 095983aae9f4628a0d83ce97911f4a18dfd89175 Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Fri, 31 Mar 2023 19:43:26 +0900 Subject: [PATCH 5/9] mirror podtemplate --- pkg/pods/pod_template.go | 17 ----- pkg/pods/task_run_spec.go | 39 ++++++++++ pkg/pods/task_run_spec_test.go | 98 +++++++++++++++++++++++++ pkg/pods/testdata/taskrunspec-not-yaml | 20 +++++ pkg/pods/testdata/taskrunspec-typo.yaml | 20 +++++ pkg/pods/testdata/taskrunspec.yaml | 20 +++++ 6 files changed, 197 insertions(+), 17 deletions(-) create mode 100644 pkg/pods/task_run_spec.go create mode 100644 pkg/pods/task_run_spec_test.go create mode 100644 pkg/pods/testdata/taskrunspec-not-yaml create mode 100644 pkg/pods/testdata/taskrunspec-typo.yaml create mode 100644 pkg/pods/testdata/taskrunspec.yaml diff --git a/pkg/pods/pod_template.go b/pkg/pods/pod_template.go index fc219910d..3cf04768e 100644 --- a/pkg/pods/pod_template.go +++ b/pkg/pods/pod_template.go @@ -19,7 +19,6 @@ import ( "github.com/tektoncd/cli/pkg/file" "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "sigs.k8s.io/yaml" ) @@ -36,19 +35,3 @@ func ParsePodTemplate(httpClient http.Client, podTemplateLocation string, valida return podTemplate, nil } - -type TaskRunSpec = []v1beta1.PipelineTaskRunSpec - -func ParseTaskRunSpec(httpClient http.Client, taskRunSpecLocation string, validate file.TypeValidator, errorMsg error) (TaskRunSpec, error) { - taskRunSpec := TaskRunSpec{} - b, err := file.LoadFileContent(httpClient, taskRunSpecLocation, validate, errorMsg) - if err != nil { - return taskRunSpec, err - } - - if err := yaml.UnmarshalStrict(b, &taskRunSpec); err != nil { - return taskRunSpec, err - } - - return taskRunSpec, nil -} diff --git a/pkg/pods/task_run_spec.go b/pkg/pods/task_run_spec.go new file mode 100644 index 000000000..f23085d38 --- /dev/null +++ b/pkg/pods/task_run_spec.go @@ -0,0 +1,39 @@ +// Copyright © 2020 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pods + +import ( + "net/http" + + "github.com/tektoncd/cli/pkg/file" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + "sigs.k8s.io/yaml" +) + +type TaskRunSpec = []v1beta1.PipelineTaskRunSpec + +func ParseTaskRunSpec(httpClient http.Client, taskRunSpecLocation string, validate file.TypeValidator, errorMsg error) (TaskRunSpec, error) { + taskRunSpec := TaskRunSpec{} + b, err := file.LoadFileContent(httpClient, taskRunSpecLocation, validate, errorMsg) + if err != nil { + return taskRunSpec, err + } + + if err := yaml.UnmarshalStrict(b, &taskRunSpec); err != nil { + return taskRunSpec, err + } + + return taskRunSpec, nil +} diff --git a/pkg/pods/task_run_spec_test.go b/pkg/pods/task_run_spec_test.go new file mode 100644 index 000000000..3b2c0593e --- /dev/null +++ b/pkg/pods/task_run_spec_test.go @@ -0,0 +1,98 @@ +// Copyright © 2020 The Tekton Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pods + +import ( + "fmt" + "net/http" + "testing" + + "github.com/tektoncd/cli/pkg/file" + "github.com/tektoncd/cli/pkg/test" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" + "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" + corev1 "k8s.io/api/core/v1" +) + +func getTestTaskRunSpec() TaskRunSpec { + runAsNonRoot := true + runAsUser := int64(1001) + + return TaskRunSpec{ + v1beta1.PipelineTaskRunSpec{ + PipelineTaskName: "first-create-file", + TaskPodTemplate: &pod.PodTemplate{ + ImagePullSecrets: nil, + HostNetwork: false, + SchedulerName: "SchedulerName", + SecurityContext: &corev1.PodSecurityContext{ + RunAsNonRoot: &runAsNonRoot, + RunAsUser: &runAsUser, + }, + }, + }, + } +} + +func TestTaskRunSpec_Local_File(t *testing.T) { + httpClient := *http.DefaultClient + podTemplateLocation := "./testdata/taskrunspec.yaml" + + podTemplate, err := ParseTaskRunSpec(httpClient, podTemplateLocation, file.IsYamlFile(), fmt.Errorf("invalid file format for %s: .yaml or .yml file extension and format required", podTemplateLocation)) + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + + test.AssertOutput(t, getTestTaskRunSpec(), podTemplate) +} + +func TestTaskRunSpec_Local_File_Typo(t *testing.T) { + httpClient := *http.DefaultClient + podTemplateLocation := "./testdata/taskrunspec-typo.yaml" + + _, err := ParseTaskRunSpec(httpClient, podTemplateLocation, file.IsYamlFile(), fmt.Errorf("invalid file format for %s: .yaml or .yml file extension and format required", podTemplateLocation)) + if err == nil { + t.Fatalf("Expected error for local file typo, but error was nil") + } + + expected := `error unmarshaling JSON: while decoding JSON: json: unknown field "ecurityContext"` + test.AssertOutput(t, expected, err.Error()) +} + +func TestTaskRunSpec_Local_File_Not_YAML(t *testing.T) { + httpClient := *http.DefaultClient + podTemplateLocation := "./testdata/taskrunspec-not-yaml" + + _, err := ParseTaskRunSpec(httpClient, podTemplateLocation, file.IsYamlFile(), fmt.Errorf("invalid file format for %s: .yaml or .yml file extension and format required", podTemplateLocation)) + if err == nil { + t.Fatalf("Expected error for local file typo, but error was nil") + } + + expected := "invalid file format for ./testdata/taskrunspec-not-yaml: .yaml or .yml file extension and format required" + test.AssertOutput(t, expected, err.Error()) +} + +func TestTaskRunSpec_Local_File_Not_Found(t *testing.T) { + httpClient := *http.DefaultClient + podTemplateLocation := "./testdata/not-exist.yaml" + + _, err := ParseTaskRunSpec(httpClient, podTemplateLocation, file.IsYamlFile(), fmt.Errorf("invalid file format for %s: .yaml or .yml file extension and format required", podTemplateLocation)) + if err == nil { + t.Fatalf("Expected error for local file typo, but error was nil") + } + + expected := "open ./testdata/not-exist.yaml: no such file or directory" + test.AssertOutput(t, expected, err.Error()) +} diff --git a/pkg/pods/testdata/taskrunspec-not-yaml b/pkg/pods/testdata/taskrunspec-not-yaml new file mode 100644 index 000000000..a97027ecb --- /dev/null +++ b/pkg/pods/testdata/taskrunspec-not-yaml @@ -0,0 +1,20 @@ +# Copyright 2020 The Tekton Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- pipelineTaskName: first-create-file + taskPodTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 diff --git a/pkg/pods/testdata/taskrunspec-typo.yaml b/pkg/pods/testdata/taskrunspec-typo.yaml new file mode 100644 index 000000000..b7a59f196 --- /dev/null +++ b/pkg/pods/testdata/taskrunspec-typo.yaml @@ -0,0 +1,20 @@ +# Copyright 2020 The Tekton Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- pipelineTaskName: first-create-file + taskPodTemplate: + schedulerName: SchedulerName + ecurityContext: + runAsNonRoot: true + runAsUser: 1001 diff --git a/pkg/pods/testdata/taskrunspec.yaml b/pkg/pods/testdata/taskrunspec.yaml new file mode 100644 index 000000000..a97027ecb --- /dev/null +++ b/pkg/pods/testdata/taskrunspec.yaml @@ -0,0 +1,20 @@ +# Copyright 2020 The Tekton Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- pipelineTaskName: first-create-file + taskPodTemplate: + schedulerName: SchedulerName + securityContext: + runAsNonRoot: true + runAsUser: 1001 From 4dba6adae73076156894cd6fbe3a04136bb22e6d Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Thu, 6 Apr 2023 09:58:31 +0900 Subject: [PATCH 6/9] use --taskrun-spec --- docs/cmd/tkn_pipeline_start.md | 2 +- docs/man/man1/tkn-pipeline-start.1 | 8 ++++---- pkg/cmd/pipeline/start.go | 2 +- pkg/cmd/pipeline/start_test.go | 2 +- pkg/cmd/pipeline/start_v1_test.go | 2 +- test/e2e/pipeline/pipeline_test.go | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/cmd/tkn_pipeline_start.md b/docs/cmd/tkn_pipeline_start.md index 681dd4a48..0446f7123 100644 --- a/docs/cmd/tkn_pipeline_start.md +++ b/docs/cmd/tkn_pipeline_start.md @@ -77,8 +77,8 @@ my-secret, my-empty-dir and my-volume-claim-template) -s, --serviceaccount string pass the serviceaccount name --showlog show logs right after starting the Pipeline --skip-optional-workspace skips the prompt for optional workspaces - --task-run-spec string local or remote file containing a TaskRunSpec definition --task-serviceaccount strings pass the service account corresponding to the task + --taskrun-spec string local or remote file containing a TaskRunSpec definition --tasks-timeout string timeout for Pipeline TaskRuns --use-param-defaults use default parameter values without prompting for input --use-pipelinerun string use this pipelinerun values to re-run the pipeline. diff --git a/docs/man/man1/tkn-pipeline-start.1 b/docs/man/man1/tkn-pipeline-start.1 index 1eb23202c..162df3dc7 100644 --- a/docs/man/man1/tkn-pipeline-start.1 +++ b/docs/man/man1/tkn-pipeline-start.1 @@ -83,14 +83,14 @@ Parameters, at least those that have no default value \fB\-\-skip\-optional\-workspace\fP[=false] skips the prompt for optional workspaces -.PP -\fB\-\-task\-run\-spec\fP="" - local or remote file containing a TaskRunSpec definition - .PP \fB\-\-task\-serviceaccount\fP=[] pass the service account corresponding to the task +.PP +\fB\-\-taskrun\-spec\fP="" + local or remote file containing a TaskRunSpec definition + .PP \fB\-\-tasks\-timeout\fP="" timeout for Pipeline TaskRuns diff --git a/pkg/cmd/pipeline/start.go b/pkg/cmd/pipeline/start.go index a6c853c26..b909e03a7 100644 --- a/pkg/cmd/pipeline/start.go +++ b/pkg/cmd/pipeline/start.go @@ -207,7 +207,7 @@ For passing the workspaces via flags: c.Flags().StringVarP(&opt.Filename, "filename", "f", "", "local or remote file name containing a Pipeline definition to start a PipelineRun") c.Flags().BoolVarP(&opt.UseParamDefaults, "use-param-defaults", "", false, "use default parameter values without prompting for input") c.Flags().StringVar(&opt.PodTemplate, "pod-template", "", "local or remote file containing a PodTemplate definition") - c.Flags().StringVar(&opt.TaskRunSpec, "task-run-spec", "", "local or remote file containing a TaskRunSpec definition") + c.Flags().StringVar(&opt.TaskRunSpec, "taskrun-spec", "", "local or remote file containing a TaskRunSpec definition") c.Flags().BoolVarP(&opt.SkipOptionalWorkspace, "skip-optional-workspace", "", false, "skips the prompt for optional workspaces") c.Flags().StringVarP(&opt.ServiceAccountName, "serviceaccount", "s", "", "pass the serviceaccount name") diff --git a/pkg/cmd/pipeline/start_test.go b/pkg/cmd/pipeline/start_test.go index 28a313227..e6bfaa6c5 100644 --- a/pkg/cmd/pipeline/start_test.go +++ b/pkg/cmd/pipeline/start_test.go @@ -1022,7 +1022,7 @@ func TestPipelineStart_ExecuteCommand_v1beta1(t *testing.T) { "-l=jemange=desfrites", "-n", "ns", "--dry-run", - "--task-run-spec", "./testdata/taskrunspec.yaml", + "--taskrun-spec", "./testdata/taskrunspec.yaml", }, namespace: "", input: c2, diff --git a/pkg/cmd/pipeline/start_v1_test.go b/pkg/cmd/pipeline/start_v1_test.go index 5ca8245f4..c49803e56 100644 --- a/pkg/cmd/pipeline/start_v1_test.go +++ b/pkg/cmd/pipeline/start_v1_test.go @@ -866,7 +866,7 @@ func TestPipelineStart_ExecuteCommand(t *testing.T) { "-l=jemange=desfrites", "-n", "ns", "--dry-run", - "--task-run-spec", "./testdata/taskrunspec.yaml", + "--taskrun-spec", "./testdata/taskrunspec.yaml", }, namespace: "", input: c2, diff --git a/test/e2e/pipeline/pipeline_test.go b/test/e2e/pipeline/pipeline_test.go index d44ec72b1..5c66b40b9 100644 --- a/test/e2e/pipeline/pipeline_test.go +++ b/test/e2e/pipeline/pipeline_test.go @@ -305,11 +305,11 @@ Waiting for logs to be available... } }) - t.Run("Start PipelineRun with --task-run-spec", func(t *testing.T) { + t.Run("Start PipelineRun with --taskrun-spec", func(t *testing.T) { tkn.MustSucceed(t, "pipeline", "start", tePipelineName, "-p=filename=output", "-w=name=shared-data,emptyDir=", - "--task-run-spec="+helper.GetResourcePath("/taskrunspec/taskrunspec.yaml"), + "--taskrun-spec="+helper.GetResourcePath("/taskrunspec/taskrunspec.yaml"), "--use-param-defaults", "--showlog") From ede20795c9f389f988878649b005797f9941f0a4 Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Sat, 8 Apr 2023 17:56:08 +0900 Subject: [PATCH 7/9] fix resource path --- test/e2e/pipeline/pipeline_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/pipeline/pipeline_test.go b/test/e2e/pipeline/pipeline_test.go index 5c66b40b9..b8e01bcc9 100644 --- a/test/e2e/pipeline/pipeline_test.go +++ b/test/e2e/pipeline/pipeline_test.go @@ -309,7 +309,7 @@ Waiting for logs to be available... tkn.MustSucceed(t, "pipeline", "start", tePipelineName, "-p=filename=output", "-w=name=shared-data,emptyDir=", - "--taskrun-spec="+helper.GetResourcePath("/taskrunspec/taskrunspec.yaml"), + "--taskrun-spec="+helper.GetResourcePath("/taskrunspec.yaml"), "--use-param-defaults", "--showlog") From 066331179c9249e3dce0dc07e91d6d16eccbcc0f Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Sat, 8 Apr 2023 17:57:21 +0900 Subject: [PATCH 8/9] add license header --- pkg/cmd/pipeline/testdata/taskrunspec.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/cmd/pipeline/testdata/taskrunspec.yaml b/pkg/cmd/pipeline/testdata/taskrunspec.yaml index d9b0ca7d4..83c33bade 100644 --- a/pkg/cmd/pipeline/testdata/taskrunspec.yaml +++ b/pkg/cmd/pipeline/testdata/taskrunspec.yaml @@ -1,3 +1,17 @@ +# Copyright 2023 The Tekton Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + - pipelineTaskName: unit-test-task taskPodTemplate: schedulerName: SchedulerName From 5f4ffd50bf7d7295467e2a5d3828ba2f2cfc3c4b Mon Sep 17 00:00:00 2001 From: Minjae Kim Date: Sat, 8 Apr 2023 17:57:41 +0900 Subject: [PATCH 9/9] fix year of license headers --- pkg/pods/task_run_spec.go | 2 +- pkg/pods/task_run_spec_test.go | 2 +- pkg/pods/testdata/taskrunspec-not-yaml | 2 +- pkg/pods/testdata/taskrunspec-typo.yaml | 2 +- pkg/pods/testdata/taskrunspec.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/pods/task_run_spec.go b/pkg/pods/task_run_spec.go index f23085d38..7a9fbc7b4 100644 --- a/pkg/pods/task_run_spec.go +++ b/pkg/pods/task_run_spec.go @@ -1,4 +1,4 @@ -// Copyright © 2020 The Tekton Authors. +// Copyright © 2023 The Tekton Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/pods/task_run_spec_test.go b/pkg/pods/task_run_spec_test.go index 3b2c0593e..1abdc0768 100644 --- a/pkg/pods/task_run_spec_test.go +++ b/pkg/pods/task_run_spec_test.go @@ -1,4 +1,4 @@ -// Copyright © 2020 The Tekton Authors. +// Copyright © 2023 The Tekton Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/pods/testdata/taskrunspec-not-yaml b/pkg/pods/testdata/taskrunspec-not-yaml index a97027ecb..02a20aa17 100644 --- a/pkg/pods/testdata/taskrunspec-not-yaml +++ b/pkg/pods/testdata/taskrunspec-not-yaml @@ -1,4 +1,4 @@ -# Copyright 2020 The Tekton Authors. +# Copyright 2023 The Tekton Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/pkg/pods/testdata/taskrunspec-typo.yaml b/pkg/pods/testdata/taskrunspec-typo.yaml index b7a59f196..93ca070c2 100644 --- a/pkg/pods/testdata/taskrunspec-typo.yaml +++ b/pkg/pods/testdata/taskrunspec-typo.yaml @@ -1,4 +1,4 @@ -# Copyright 2020 The Tekton Authors. +# Copyright 2023 The Tekton Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/pkg/pods/testdata/taskrunspec.yaml b/pkg/pods/testdata/taskrunspec.yaml index a97027ecb..02a20aa17 100644 --- a/pkg/pods/testdata/taskrunspec.yaml +++ b/pkg/pods/testdata/taskrunspec.yaml @@ -1,4 +1,4 @@ -# Copyright 2020 The Tekton Authors. +# Copyright 2023 The Tekton Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.