diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types.go b/pkg/apis/pipeline/v1alpha1/taskrun_types.go index 5b96cf14a9d..5e19d35eab9 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types.go @@ -32,7 +32,6 @@ var _ apis.Defaultable = (*TaskRun)(nil) // TaskRunSpec defines the desired state of TaskRun type TaskRunSpec struct { - Trigger TaskTrigger `json:"trigger,omitempty"` // +optional Inputs TaskRunInputs `json:"inputs,omitempty"` // +optional @@ -92,28 +91,6 @@ type TaskRunOutputs struct { Params []Param `json:"params,omitempty"` } -// TaskTriggerType indicates the mechanism by which this TaskRun was created. -type TaskTriggerType string - -const ( - // TaskTriggerTypeManual indicates that this TaskRun was invoked manually by a user. - TaskTriggerTypeManual TaskTriggerType = "manual" - - // TaskTriggerTypePipelineRun indicates that this TaskRun was created by a controller - // attempting to realize a PipelineRun. In this case the `name` will refer to the name - // of the PipelineRun. - TaskTriggerTypePipelineRun TaskTriggerType = "pipelineRun" -) - -// TaskTrigger describes what triggered this Task to run. It could be triggered manually, -// or it may have been part of a PipelineRun in which case this ref would refer -// to the corresponding PipelineRun. -type TaskTrigger struct { - Type TaskTriggerType `json:"type"` - // +optional - Name string `json:"name,omitempty,omitempty"` -} - var taskRunCondSet = apis.NewBatchConditionSet() // TaskRunStatus defines the observed state of TaskRun diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_validation.go b/pkg/apis/pipeline/v1alpha1/taskrun_validation.go index 4f44b9ce018..00094694dc0 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_validation.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_validation.go @@ -114,27 +114,6 @@ func validatePipelineResources(ctx context.Context, resources []TaskResourceBind return nil } -// Validate validates that the task trigger is of a known type. If it was triggered by a PipelineRun, the -// name of the trigger should be the name of a PipelienRun. -func (r TaskTrigger) Validate(ctx context.Context, path string) *apis.FieldError { - if r.Type == "" { - return nil - } - - taskType := strings.ToLower(string(r.Type)) - for _, allowed := range []TaskTriggerType{TaskTriggerTypePipelineRun, TaskTriggerTypeManual} { - allowedType := strings.ToLower(string(allowed)) - - if taskType == allowedType { - if allowedType == strings.ToLower(string(TaskTriggerTypePipelineRun)) && r.Name == "" { - return apis.ErrMissingField(fmt.Sprintf("%s.name", path)) - } - return nil - } - } - return apis.ErrInvalidValue(string(r.Type), fmt.Sprintf("%s.type", path)) -} - func validateParameters(params []Param) *apis.FieldError { // Template must not duplicate parameter names. seen := map[string]struct{}{} diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_validation_test.go b/pkg/apis/pipeline/v1alpha1/taskrun_validation_test.go index 28d87106369..8a431009b47 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_validation_test.go @@ -72,11 +72,7 @@ func TestTaskRun_Validate(t *testing.T) { Spec: TaskRunSpec{ TaskRef: &TaskRef{ Name: "taskrefname", - }, - Trigger: TaskTrigger{ - Type: TaskTriggerTypePipelineRun, - Name: "testtriggername", - }, + } }, } if err := tr.Validate(context.Background()); err != nil { @@ -99,9 +95,6 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { name: "invalid taskref name", spec: TaskRunSpec{ TaskRef: &TaskRef{}, - Trigger: TaskTrigger{ - Type: TaskTriggerTypeManual, - }, }, wantErr: apis.ErrMissingField("spec.taskref.name, spec.taskspec"), }, @@ -117,19 +110,6 @@ func TestTaskRunSpec_Invalidate(t *testing.T) { }, wantErr: apis.ErrInvalidValue("wrongtype", "spec.trigger.type"), }, - { - name: "triggered by pipelinerun without name", - spec: TaskRunSpec{ - TaskRef: &TaskRef{ - Name: "taskrefname", - }, - Trigger: TaskTrigger{ - Type: TaskTriggerTypePipelineRun, - Name: "", - }, - }, - wantErr: apis.ErrMissingField("spec.trigger.name"), - }, { name: "invalid taskref and taskspec together", spec: TaskRunSpec{ @@ -165,34 +145,6 @@ func TestTaskRunSpec_Validate(t *testing.T) { name string spec TaskRunSpec }{ - { - name: "task trigger run type", - spec: TaskRunSpec{ - TaskRef: &TaskRef{ - Name: "taskrefname", - }, - Trigger: TaskTrigger{ - Type: TaskTriggerTypePipelineRun, - Name: "testtrigger", - }, - Results: &Results{ - URL: "http://www.google.com", - Type: "gcs", - }, - }, - }, - { - name: "task trigger run type with different capitalization", - spec: TaskRunSpec{ - TaskRef: &TaskRef{ - Name: "taskrefname", - }, - Trigger: TaskTrigger{ - Type: "PiPeLiNeRuN", - Name: "testtrigger", - }, - }, - }, { name: "taskspec without a taskRef", spec: TaskRunSpec{ diff --git a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go index d3ef09cdc40..4c2a2f2fa4b 100644 --- a/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go @@ -1317,7 +1317,6 @@ func (in *TaskRunOutputs) DeepCopy() *TaskRunOutputs { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TaskRunSpec) DeepCopyInto(out *TaskRunSpec) { *out = *in - out.Trigger = in.Trigger in.Inputs.DeepCopyInto(&out.Inputs) in.Outputs.DeepCopyInto(&out.Outputs) if in.Results != nil { @@ -1507,22 +1506,6 @@ func (in *TaskSpec) DeepCopy() *TaskSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TaskTrigger) DeepCopyInto(out *TaskTrigger) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskTrigger. -func (in *TaskTrigger) DeepCopy() *TaskTrigger { - if in == nil { - return nil - } - out := new(TaskTrigger) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TestResult) DeepCopyInto(out *TestResult) { *out = *in diff --git a/test/builder/task.go b/test/builder/task.go index 44eea93f534..e511a0ca63c 100644 --- a/test/builder/task.go +++ b/test/builder/task.go @@ -450,16 +450,6 @@ func TaskRunTaskSpec(ops ...TaskSpecOp) TaskRunSpecOp { } } -// TaskTrigger set the TaskTrigger, with specified name and type, to the TaskRunSpec. -func TaskTrigger(name string, triggerType v1alpha1.TaskTriggerType) TaskRunSpecOp { - return func(trs *v1alpha1.TaskRunSpec) { - trs.Trigger = v1alpha1.TaskTrigger{ - Name: name, - Type: triggerType, - } - } -} - // TaskRunServiceAccount sets the serviceAccount to the TaskRunSpec. func TaskRunServiceAccount(sa string) TaskRunSpecOp { return func(trs *v1alpha1.TaskRunSpec) { diff --git a/test/builder/task_test.go b/test/builder/task_test.go index 28f9c745203..215617389c9 100644 --- a/test/builder/task_test.go +++ b/test/builder/task_test.go @@ -217,7 +217,6 @@ func TestTaskRunWithTaskSpec(t *testing.T) { tb.TaskRunTaskSpec( tb.Step("step", "image", tb.Command("/mycmd")), ), - tb.TaskTrigger("mytrigger", v1alpha1.TaskTriggerTypeManual), tb.TaskRunServiceAccount("sa"), tb.TaskRunTimeout(2*time.Minute), )) @@ -233,10 +232,6 @@ func TestTaskRunWithTaskSpec(t *testing.T) { Command: []string{"/mycmd"}, }}, }, - Trigger: v1alpha1.TaskTrigger{ - Name: "mytrigger", - Type: v1alpha1.TaskTriggerTypeManual, - }, ServiceAccount: "sa", Timeout: &metav1.Duration{Duration: 2 * time.Minute}, }, diff --git a/test/cluster_resource_test.go b/test/cluster_resource_test.go index d7d12ef6e9e..f5283452de6 100644 --- a/test/cluster_resource_test.go +++ b/test/cluster_resource_test.go @@ -127,9 +127,6 @@ func getClusterResourceTaskRun(namespace, name, taskName, resName string) *v1alp TaskRef: &v1alpha1.TaskRef{ Name: taskName, }, - Trigger: v1alpha1.TaskTrigger{ - Type: v1alpha1.TaskTriggerTypeManual, - }, Inputs: v1alpha1.TaskRunInputs{ Resources: []v1alpha1.TaskResourceBinding{{ Name: "target-cluster",