@@ -47,8 +47,10 @@ A `Run` definition supports the following fields:
4747 - [ ` metadata ` ] [ kubernetes-overview ] - Specifies the metadata that uniquely identifies the
4848 ` Run ` , such as a ` name ` .
4949 - [ ` spec ` ] [ kubernetes-overview ] - Specifies the configuration for the ` Run ` .
50- - [ ` ref ` ] ( #specifying-the-target-custom-task ) - Specifies the type and
50+ - [ ` ref ` ] ( #1- specifying-the-target-custom-task-with-ref ) - Specifies the type and
5151 (optionally) name of the custom task type to execute.
52+ - [ ` spec ` ] ( #2-specifying-the-target-custom-task-by-embedding-its-spec ) - Embed the custom task resource spec
53+ directly in a ` Run ` .
5254- Optional:
5355 - [ ` params ` ] ( #specifying-parameters ) - Specifies the desired execution
5456 parameters for the custom task.
@@ -64,6 +66,19 @@ A `Run` definition supports the following fields:
6466
6567### Specifying the target Custom Task
6668
69+ A custom task resource's ` Spec ` may be directly embedded in the ` Run ` or it may
70+ be referred to by a ` Ref ` . But, not both at the same time.
71+
72+ 1 . [ Specifying the target Custom Task with ref] ( #1-specifying-the-target-custom-task-with-ref )
73+ Referring a custom task (i.e. ` Ref ` ) promotes reuse of custom task definitions.
74+
75+ 2 . [ Specifying the target Custom Task by embedding its spec] ( #2-specifying-the-target-custom-task-by-embedding-its-spec )
76+ Embedding a custom task (i.e. ` Spec ` ) helps in avoiding name collisions with other users within the same namespace.
77+ Additionally, in a pipeline with multiple embedded custom tasks, the details of entire pipeline can be fetched in a
78+ single API request.
79+
80+ ### 1. Specifying the target Custom Task with ref
81+
6782To specify the custom task type you want to execute in your ` Run ` , use the
6883` ref ` field as shown below:
6984
@@ -99,6 +114,45 @@ In either case, if the named resource cannot be found, or if unnamed tasks are
99114not supported, the custom task controller should update the `Run`'s status to
100115indicate the error.
101116
117+ # ## 2. Specifying the target Custom Task by embedding its spec
118+
119+ To specify the custom task spec, it can be embedded directly into a
120+ `Run`'s spec as shown below :
121+
122+ ` ` ` yaml
123+ apiVersion: tekton.dev/v1alpha1
124+ kind: Run
125+ metadata:
126+ name: embedded-run
127+ spec:
128+ spec:
129+ apiVersion: example.dev/v1alpha1
130+ kind: Example
131+ spec:
132+ field1: value1
133+ field2: value2
134+ ` ` `
135+
136+ This initiates the execution of a `Run` of a custom task of type `Example`, in
137+ the `example.dev` API group, with the version `v1alpha1`.
138+
139+ # ### Developer guide for custom controllers supporting `spec`.
140+
141+ 1. A custom controller may or may not support a `Spec`. In cases where it is
142+ not supported the custom controller should respond with proper validation error.
143+
144+ 2. Validation of the fields of the custom task is delegated to the custom task controller. It is recommended to
145+ implement validations as asynchronous
146+ (i.e. at reconcile time), rather than part of the webhook. Using a webhook for validation is problematic because, it
147+ is not possible to filter custom task resource objects before validation step, as a result each custom task resource
148+ has to undergo validation by all the installed custom task controllers.
149+
150+ 3. A custom task may have an empty spec, but cannot have an empty
151+ ` ApiVersion` and `Kind`. Custom task controllers should handle
152+ an empty spec, either with a default behaviour, in a case no default
153+ behaviour is supported then, appropriate validation error should be
154+ updated to the `Run`'s status.
155+
102156# ## Specifying `Parameters`
103157
104158If a custom task supports [`parameters`](tasks.md#parameters), you can use the
0 commit comments