You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This TEP is updated with the new proposed solution where we now specify
the default value for results at the time where they are consumed.
Signed-off-by: vinamra28 <jvinamra776@gmail.com>
Adding a default value to `Results` is optional; validation of a `Task` doesn't
465
-
fail if the default value isn't provided.
466
-
467
-
Adding a default value to a `Result` will guarantee that it will hold a value even
468
-
if the `Task` fails to produce it. If a `Task` does not produce a `Result` that does not
469
-
have a default value, then the `Task` should fail - see [tektoncd/pipeline#3497](https://github.com/tektoncd/pipeline/issues/3497) for further details.
497
+
If the `Task` doesn't produce any result then it should fail. In order to
498
+
continue with the execution of `Pipeline`, `onError: continue` should be added
499
+
in the `PipelineTask` which we anticipate to fail and subsequent `Tasks`
500
+
which are consuming the results produced by the previous `Task` should have a
501
+
default value specified.
470
502
471
503
The proposed solution can be used to solve the above use cases as follows:
In the above example, if the value of parameter `checkName` is not passed,
691
+
the `Task` is failed but in order to continue the execution of the `Pipeline`,
692
+
we use the `onError: continue` flag and
693
+
658
694
In the above example, even if the value of parameter `checkName` is not passed,
659
-
default value of `Result` will be produced `passed` and Pipeline's execution will
695
+
default value of `Result` will be produced `failed` and Pipeline's execution will
660
696
be continued. The only case when the execution of `Pipeline` is stopped when
661
697
the wrong value of parameter `checkName` is passed.
662
698
@@ -670,6 +706,103 @@ Having default results defined in check-name-matches Task will fix the Pipeline.
670
706
671
707
## Alternatives
672
708
709
+
### Specifying Default Value during Runtime
710
+
711
+
Adding an optional field - `default` for a `Result` which can be specified
712
+
during runtime, i.e., in `TaskRun` or `Pipeline` for a `Task` or in `PipelineRun` for a `Pipeline`.
713
+
714
+
```yaml
715
+
apiVersion: tekton.dev/v1beta1
716
+
kind: Task
717
+
metadata:
718
+
name: task
719
+
spec:
720
+
results:
721
+
- name: merge_status
722
+
description: whether to rebase or squash
723
+
type: string
724
+
- name: branches
725
+
description: branches in the repository
726
+
type: array
727
+
- name: images
728
+
type: object
729
+
properties:
730
+
node:
731
+
type: string
732
+
gcloud:
733
+
type: string
734
+
steps:
735
+
...
736
+
---
737
+
apiVersion: tekton.dev/v1beta1
738
+
kind: TaskRun
739
+
metadata:
740
+
name: task
741
+
spec:
742
+
taskRef:
743
+
name: task
744
+
results:
745
+
- name: merge_status
746
+
default: rebase
747
+
...
748
+
```
749
+
750
+
Passing the default value for the `Result` at runtime is optional; validation
751
+
of `TaskRun` or `Pipeline` or `PipelineRun` doesn't fail if the value isn't provided.
752
+
753
+
Adding a default value to `Results` is optional; validation of a `Task` doesn't
754
+
fail if the default value isn't provided.
755
+
756
+
Adding a default value to a `Result` will guarantee that it will hold a value even
757
+
if the `Task` fails to produce it. If a `Task` does not produce a `Result` that does not
758
+
have a default value, then the `Task` should fail - see [tektoncd/pipeline#3497][tektoncd/pipeline#3497] for further details.
759
+
760
+
Values specified in `TaskRun` or `Pipeline` should be overwritten by declaring
761
+
`Task`itself, if `Task` declares a `Result` then it should be considered as
762
+
the final value for that result.
763
+
764
+
### Specifying Default Value at the time of Authoring the Task
765
+
766
+
Allow `Results` to declare an optional field as `default`. When a `Task` fails to
767
+
produce a `Result` but has a default value specified, then the `Task` does not fail. When a `Task` fails
768
+
to produce a `Result` that doesn't have any default value specified, then then the `Task` will fail.
769
+
770
+
```yaml
771
+
apiVersion: tekton.dev/v1beta1
772
+
kind: Task
773
+
metadata:
774
+
name: task
775
+
spec:
776
+
results:
777
+
- name: merge_status
778
+
description: whether to rebase or squash
779
+
type: string
780
+
default: "rebase"
781
+
- name: branches
782
+
description: branches in the repository
783
+
type: array
784
+
default:
785
+
- "foo"
786
+
- "bar"
787
+
- name: images
788
+
type: object
789
+
properties:
790
+
node:
791
+
type: string
792
+
gcloud:
793
+
type: string
794
+
default:
795
+
node: "16"
796
+
gcloud: "true"
797
+
steps:
798
+
...
799
+
```
800
+
801
+
This solution only solves the issue of `Tasks` not failing when they
802
+
don't produce `Results` as discussed in [tektoncd/pipeline#3497][tektoncd/pipeline#3497].
803
+
However, it does not addressed the use case where an user can
804
+
have different default values at runtime based on their `Pipeline`.
805
+
673
806
### Declaring Results as Optional
674
807
675
808
Allow `Results` to declare an optional field as `optional`. When a `Task` fails to
@@ -704,7 +837,7 @@ spec:
704
837
```
705
838
706
839
However, this solution only solves the issue of `Tasks` not failing when they don't
707
-
produce `Results` as discussed in [tektoncd/pipeline#3497](https://github.com/tektoncd/pipeline/issues/3497).
840
+
produce `Results` as discussed in [tektoncd/pipeline#3497][tektoncd/pipeline#3497].
708
841
It does not address the use cases for providing default `Results` that can be consumed in subsequent `Tasks`.
709
842
710
843
@@ -721,3 +854,6 @@ Determine if we need default `Results` declared at runtime in the future, and ho
721
854
* [Issue reported - "when" expressions do not match user expectations](https://github.com/tektoncd/pipeline/issues/3345)
722
855
723
856
* [Accessing Execution status of any DAG task from finally](https://github.com/tektoncd/community/blob/master/teps/0028-task-execution-status-at-runtime.md)
0 commit comments