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