Skip to content

Commit

Permalink
Remove the Trigger field from TaskRun.
Browse files Browse the repository at this point in the history
This field is not currently used, and it's usage should be replaced
with labels/annotations. This commit removes it now, before anyone
takes a dependency on it.

At a later time we can decide on the correct label/annotation usage
for this information and start writing that data.
  • Loading branch information
dlorenc committed May 13, 2019
1 parent 75d6dab commit 2d03241
Show file tree
Hide file tree
Showing 20 changed files with 2 additions and 205 deletions.
6 changes: 0 additions & 6 deletions docs/taskruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ metadata:
spec:
taskRef:
name: read-task
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down Expand Up @@ -322,8 +320,6 @@ kind: TaskRun
metadata:
name: build-push-task-run-2
spec:
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down Expand Up @@ -356,8 +352,6 @@ metadata:
spec:
taskRef:
name: read-task
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down
12 changes: 0 additions & 12 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ metadata:
spec:
taskRef:
name: echo-hello-world
trigger:
type: manual
```

To apply the yaml files use the following command:
Expand Down Expand Up @@ -86,8 +84,6 @@ spec:
taskRef:
name: echo-hello-world
taskSpec: null
trigger:
type: manual
status:
conditions:
- lastTransitionTime: 2018-12-11T15:50:09Z
Expand Down Expand Up @@ -206,8 +202,6 @@ metadata:
spec:
taskRef:
name: build-docker-image-from-git-source
trigger:
type: manual
inputs:
resources:
- name: docker-source
Expand Down Expand Up @@ -294,8 +288,6 @@ spec:
taskRef:
name: build-docker-image-from-git-source
taskSpec: null
trigger:
type: manual
status:
conditions:
- lastTransitionTime: 2018-12-11T18:15:09Z
Expand Down Expand Up @@ -434,8 +426,6 @@ metadata:
spec:
pipelineRef:
name: tutorial-pipeline
trigger:
type: manual
resources:
- name: source-repo
resourceRef:
Expand Down Expand Up @@ -489,8 +479,6 @@ spec:
resourceRef:
name: skaffold-image-leeroy-web
serviceAccount: ""
trigger:
type: manual
status:
conditions:
- lastTransitionTime: 2018-12-11T20:32:41Z
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelineruns/output-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ metadata:
spec:
pipelineRef:
name: output-pipeline
trigger:
type: manual
serviceAccount: 'default'
resources:
- name: source-repo
Expand Down
2 changes: 0 additions & 2 deletions examples/pipelineruns/pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ metadata:
spec:
pipelineRef:
name: demo-pipeline
trigger:
type: manual
serviceAccount: 'default'
resources:
- name: source-repo
Expand Down
2 changes: 0 additions & 2 deletions examples/taskruns/gcs-resource-spec-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ spec:
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'ls -al /workspace/rules/rules_docker-master'] # tests build-gcs resource
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down
2 changes: 0 additions & 2 deletions examples/taskruns/git-resource-spec-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ spec:
image: ubuntu
command: ["/bin/bash"]
args: ['-c', 'cat /workspace/skaffold/README.md'] # tests that resource spec and task spec can be defined in taskrun
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down
2 changes: 0 additions & 2 deletions examples/taskruns/private-taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ spec:
image: quay.io/rhpipeline/skopeo:alpine
command: ["skopeo"]
args: ["copy", "docker://gcr.io/build-crd-testing/secret-sauce", "dir:///tmp/"]
trigger:
type: manual
2 changes: 0 additions & 2 deletions examples/taskruns/taskrun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ metadata:
spec:
taskRef:
name: build-push-kaniko
trigger:
type: manual
inputs:
resources:
- name: workspace
Expand Down
15 changes: 1 addition & 14 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ func TestPipelineRun_Invalidate(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "pipelinelineName",
},
Spec: PipelineRunSpec{
Trigger: PipelineTrigger{
Type: PipelineTriggerTypeManual,
},
},
Spec: PipelineRunSpec{},
},
want: apis.ErrMissingField("pipelinerun.spec.Pipelineref.Name"),
}, {
Expand All @@ -74,9 +70,6 @@ func TestPipelineRun_Invalidate(t *testing.T) {
PipelineRef: PipelineRef{
Name: "prname",
},
Trigger: PipelineTrigger{
Type: "badtype",
},
},
},
want: apis.ErrInvalidValue("badtype", "pipelinerun.spec.trigger.type"),
Expand All @@ -90,9 +83,6 @@ func TestPipelineRun_Invalidate(t *testing.T) {
PipelineRef: PipelineRef{
Name: "prname",
},
Trigger: PipelineTrigger{
Type: PipelineTriggerTypeManual,
},
Timeout: &metav1.Duration{Duration: -48 * time.Hour},
},
},
Expand All @@ -119,9 +109,6 @@ func TestPipelineRun_Validate(t *testing.T) {
PipelineRef: PipelineRef{
Name: "prname",
},
Trigger: PipelineTrigger{
Type: "manual",
},
Results: &Results{
URL: "http://www.google.com",
Type: "gcs",
Expand Down
23 changes: 0 additions & 23 deletions pkg/apis/pipeline/v1alpha1/taskrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 0 additions & 26 deletions pkg/apis/pipeline/v1alpha1/taskrun_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ func (ts *TaskRunSpec) Validate(ctx context.Context) *apis.FieldError {
return apis.ErrMissingField("spec.taskref.name", "spec.taskspec")
}

// Check for Trigger
if err := ts.Trigger.Validate(ctx, "spec.trigger"); err != nil {
return err
}

// check for input resources
if err := ts.Inputs.Validate(ctx, "spec.Inputs"); err != nil {
return err
Expand Down Expand Up @@ -114,27 +109,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{}{}
Expand Down
67 changes: 0 additions & 67 deletions pkg/apis/pipeline/v1alpha1/taskrun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ func TestTaskRun_Validate(t *testing.T) {
TaskRef: &TaskRef{
Name: "taskrefname",
},
Trigger: TaskTrigger{
Type: TaskTriggerTypePipelineRun,
Name: "testtriggername",
},
},
}
if err := tr.Validate(context.Background()); err != nil {
Expand All @@ -99,37 +95,9 @@ 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"),
},
{
name: "invalid trigger type",
spec: TaskRunSpec{
TaskRef: &TaskRef{
Name: "taskrefname",
},
Trigger: TaskTrigger{
Type: "wrongtype",
},
},
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{
Expand All @@ -142,9 +110,6 @@ func TestTaskRunSpec_Invalidate(t *testing.T) {
Image: "myimage",
}},
},
Trigger: TaskTrigger{
Type: "manual",
},
},
wantErr: apis.ErrDisallowedFields("spec.taskspec", "spec.taskref"),
},
Expand All @@ -165,34 +130,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{
Expand All @@ -202,10 +139,6 @@ func TestTaskRunSpec_Validate(t *testing.T) {
Image: "myimage",
}},
},
Trigger: TaskTrigger{
Type: "PiPeLiNeRuN",
Name: "testtrigger",
},
},
},
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions tekton/ci-images-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ metadata:
spec:
taskRef:
name: publish-ci-images
trigger:
type: manual
inputs:
resources:
- name: source
Expand Down
Loading

0 comments on commit 2d03241

Please sign in to comment.