Skip to content

Commit

Permalink
Allow references to ClusterTasks in v1 Pipeline Tasks
Browse files Browse the repository at this point in the history
We cannot yet remove support for ClusterTasks, so they should continue
to be referenceable from v1 Pipelines. This commit removes an error
message associated with referencing ClusterTasks in v1 Pipelines.
  • Loading branch information
lbernick authored and tekton-robot committed Apr 27, 2023
1 parent 7d6cd81 commit 0d8abac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4516,7 +4516,11 @@ More info: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/sec
<th>Description</th>
</tr>
</thead>
<tbody><tr><td><p>&#34;Task&#34;</p></td>
<tbody><tr><td><p>&#34;ClusterTask&#34;</p></td>
<td><p>ClusterTaskRefKind is the task type for a reference to a task with cluster scope.
ClusterTasks are not supported in v1, but v1 types may reference ClusterTasks.</p>
</td>
</tr><tr><td><p>&#34;Task&#34;</p></td>
<td><p>NamespacedTaskKind indicates that the task type has a namespaced scope.</p>
</td>
</tr></tbody>
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (pt PipelineTask) Validate(ctx context.Context) (errs *apis.FieldError) {
taskKinds := map[TaskKind]bool{
"": true,
NamespacedTaskKind: true,
ClusterTaskRefKind: true,
}
// Pipeline task having taskRef/taskSpec with APIVersion is classified as custom task
switch {
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/pipeline/v1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ func TestPipeline_Validate_Success(t *testing.T) {
Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "bar", Kind: NamespacedTaskKind}}},
},
},
}, {
name: "valid reference to clusterTask",
p: &Pipeline{
ObjectMeta: metav1.ObjectMeta{Name: "pipeline"},
Spec: PipelineSpec{
Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "bar", Kind: ClusterTaskRefKind}}},
},
},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pipeline/v1/taskref_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type TaskKind string
const (
// NamespacedTaskKind indicates that the task type has a namespaced scope.
NamespacedTaskKind TaskKind = "Task"
// ClusterTaskRefKind is the task type for a reference to a task with cluster scope.
// ClusterTasks are not supported in v1, but v1 types may reference ClusterTasks.
ClusterTaskRefKind TaskKind = "ClusterTask"
)

// IsCustomTask checks whether the reference is to a Custom Task
Expand Down

0 comments on commit 0d8abac

Please sign in to comment.