Skip to content

Commit

Permalink
Do not allow use of deprecated Conditions with custom tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
GregDritschler authored and tekton-robot committed Dec 7, 2020
1 parent 75f3776 commit 2ba62c8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/pipelines.md
Expand Up @@ -972,6 +972,8 @@ Pipelines do not directly support passing the following items to custom tasks:
* Service account name
* Pod templates

A pipeline task that references a custom task cannot reference `Conditions`.
`Conditions` are deprecated. Use [`WhenExpressions`](#guard-task-execution-using-whenexpressions) instead.

## Code examples

Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_validation.go
Expand Up @@ -144,6 +144,11 @@ func validatePipelineTask(ctx context.Context, t PipelineTask, taskNames sets.St
if t.TaskRef.Kind == "" {
errs = errs.Also(apis.ErrInvalidValue("custom task ref must specify kind", "taskRef.kind"))
}
// Conditions are deprecated so the effort to support them with custom tasks is not justified.
// When expressions should be used instead.
if len(t.Conditions) > 0 {
errs = errs.Also(apis.ErrInvalidValue("custom tasks do not support conditions - use when expressions instead", "conditions"))
}
// TODO(#3133): Support these features if possible.
if t.Retries > 0 {
errs = errs.Also(apis.ErrInvalidValue("custom tasks do not support retries", "retries"))
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_validation_test.go
Expand Up @@ -582,6 +582,20 @@ func TestValidatePipelineTasks_Failure(t *testing.T) {
Paths: []string{"tasks[0].taskRef.kind"},
},
wc: enableFeature(t, "enable-custom-tasks"),
}, {
name: "pipelinetask custom task doesn't support conditions",
tasks: []PipelineTask{{
Name: "foo",
Conditions: []PipelineTaskCondition{{
ConditionRef: "some-condition",
}},
TaskRef: &TaskRef{APIVersion: "example.dev/v0", Kind: "Example"},
}},
expectedError: apis.FieldError{
Message: `invalid value: custom tasks do not support conditions - use when expressions instead`,
Paths: []string{"tasks[0].conditions"},
},
wc: enableFeature(t, "enable-custom-tasks"),
}, {
name: "pipelinetask custom task doesn't support retries",
tasks: []PipelineTask{{
Expand Down

0 comments on commit 2ba62c8

Please sign in to comment.