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 committed Apr 26, 2023
1 parent 7d6cd81 commit bf9812c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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 bf9812c

Please sign in to comment.