Skip to content

Commit

Permalink
TEP-0076 (array results and indexing into array)promoted to stable
Browse files Browse the repository at this point in the history
Pipelines 0.45 promoted array results and indexing into array param
(proposed in TEP-0076) to beta. This commit is promoting these two
features to stable such that these features can be used by the task
authors and pipeline authors in a cluster when enable-api-fields is
either set to alpha, beta or stable.

Closes #6816

Signed-off-by: Yongxuan Zhang [email protected]
  • Loading branch information
Yongxuanzhang committed Jan 3, 2024
1 parent 8ad2da9 commit c998128
Show file tree
Hide file tree
Showing 18 changed files with 9 additions and 396 deletions.
1 change: 0 additions & 1 deletion docs/additional-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ Features currently in "beta" are:

| Feature | Proposal | Alpha Release | Beta Release | Individual Flag |
|:------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|:---------------------------------------------------------------------|:------------------------------|
| [Array Results and Array Indexing](pipelineruns.md#specifying-parameters) | [TEP-0076](https://github.com/tektoncd/community/blob/main/teps/0076-array-result-types.md) | [v0.38.0](https://github.com/tektoncd/pipeline/releases/tag/v0.38.0) | [v0.45.0](https://github.com/tektoncd/pipeline/releases/tag/v0.45.0) | |
| [Object Parameters and Results](pipelineruns.md#specifying-parameters) | [TEP-0075](https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md) | | [v0.46.0](https://github.com/tektoncd/pipeline/releases/tag/v0.46.0) | |
| [Remote Tasks](./taskruns.md#remote-tasks) and [Remote Pipelines](./pipelineruns.md#remote-pipelines) | [TEP-0060](https://github.com/tektoncd/community/blob/main/teps/0060-remote-resolution.md) | | [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0) | |
| [`Provenance` field in Status](pipeline-api.md#provenance) | [issue#5550](https://github.com/tektoncd/pipeline/issues/5550) | [v0.41.0](https://github.com/tektoncd/pipeline/releases/tag/v0.41.0) | [v0.48.0](https://github.com/tektoncd/pipeline/releases/tag/v0.48.0) | `enable-provenance-in-status` |
Expand Down
6 changes: 3 additions & 3 deletions docs/pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ spec:
If the `Param` value passed in by `PipelineRun` is **NOT** in the predefined `enum` list, the `PipelineRun` will fail with reason `InvalidParamValue`.

If a `PipelineTask` references a `Task` with `enum`, the `enums` specified in the Pipeline `spec.params` (pipeline-level `enum`) must be
a **subset** of the `enums` specified in the referenced `Task` (task-level `enum`). An empty pipeline-level `enum` is invalid
in this scenario since an empty `enum` set indicates a "universal set" which allows all possible values. The same rules apply to `Pipelines` with embbeded `Tasks`.
a **subset** of the `enums` specified in the referenced `Task` (task-level `enum`). An empty pipeline-level `enum` is invalid
in this scenario since an empty `enum` set indicates a "universal set" which allows all possible values. The same rules apply to `Pipelines` with embbeded `Tasks`.

In the below example, the referenced `Task` accepts `v1` and `v2` as valid values, the `Pipeline` further restricts the valid value to `v1`.

Expand Down Expand Up @@ -1375,7 +1375,7 @@ results:

For an end-to-end example, see [`Results` in a `PipelineRun`](../examples/v1/pipelineruns/pipelinerun-results.yaml).

Object result and array result are beta features,
Object result is beta feature,
see [`Array and Object Results` in a `PipelineRun`](../examples/v1/pipelineruns/beta/pipeline-emitting-results.yaml).

```yaml
Expand Down
7 changes: 1 addition & 6 deletions pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,13 @@ func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object type parameter", config.BetaAPIFields).ViaFieldIndex("params", i))
}
}
// Indexing into array parameters
arrayParamIndexingRefs := ps.GetIndexingReferencesToArrayParams()
if len(arrayParamIndexingRefs) != 0 {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "indexing into array parameters", config.BetaAPIFields))
}
// array and object results
for i, result := range ps.Results {
switch result.Type {
case ResultsTypeObject:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i))
case ResultsTypeArray:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i))
// Stable feature
case ResultsTypeString:
default:
}
Expand Down
67 changes: 0 additions & 67 deletions pkg/apis/pipeline/v1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4150,38 +4150,6 @@ func TestPipelineWithBetaFields(t *testing.T) {
name string
spec PipelineSpec
}{{
name: "array indexing in Tasks",
spec: PipelineSpec{
Params: []ParamSpec{
{Name: "first-param", Type: ParamTypeArray, Default: NewStructuredValues("default-value", "default-value-again")},
},
Tasks: []PipelineTask{{
Name: "foo",
Params: Params{
{Name: "first-task-first-param", Value: *NewStructuredValues("$(params.first-param[0])")},
},
TaskRef: &TaskRef{Name: "foo"},
}},
},
}, {
name: "array indexing in Finally",
spec: PipelineSpec{
Params: []ParamSpec{
{Name: "first-param", Type: ParamTypeArray, Default: NewStructuredValues("default-value", "default-value-again")},
},
Tasks: []PipelineTask{{
Name: "foo",
TaskRef: &TaskRef{Name: "foo"},
}},
Finally: []PipelineTask{{
Name: "bar",
Params: Params{
{Name: "first-task-first-param", Value: *NewStructuredValues("$(params.first-param[0])")},
},
TaskRef: &TaskRef{Name: "bar"},
}},
},
}, {
name: "pipeline tasks - use of resolver",
spec: PipelineSpec{
Tasks: []PipelineTask{{
Expand Down Expand Up @@ -4258,41 +4226,6 @@ func TestPipelineWithBetaFields(t *testing.T) {
}},
}},
},
}, {
name: "array results",
spec: PipelineSpec{
Tasks: []PipelineTask{{
Name: "valid-pipeline-task",
TaskRef: &TaskRef{Name: "foo-task"},
}},
Results: []PipelineResult{{Name: "my-array-result", Type: ResultsTypeArray, Value: *NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}},
},
}, {
name: "array results in Tasks",
spec: PipelineSpec{
Tasks: []PipelineTask{{
Name: "valid-pipeline-task",
TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{
Steps: []Step{{Image: "busybox", Script: "echo hello"}},
Results: []TaskResult{{Name: "my-array-result", Type: ResultsTypeArray}},
}},
}},
},
}, {
name: "array results in Finally",
spec: PipelineSpec{
Tasks: []PipelineTask{{
Name: "valid-pipeline-task",
TaskRef: &TaskRef{Name: "foo-task"},
}},
Finally: []PipelineTask{{
Name: "valid-finally-task",
TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{
Steps: []Step{{Image: "busybox", Script: "echo hello"}},
Results: []TaskResult{{Name: "my-array-result", Type: ResultsTypeArray}},
}},
}},
},
}, {
name: "object results",
spec: PipelineSpec{
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/pipeline/v1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ const (
// ReasonObjectParameterMissKeys indicates that the object param value provided from PipelineRun spec
// misses some keys required for the object param declared in Pipeline spec.
PipelineRunReasonObjectParameterMissKeys PipelineRunReason = "ObjectParameterMissKeys"
// ReasonParamArrayIndexingInvalid indicates that the use of param array indexing is not under correct api fields feature gate
// or the array is out of bound.
// ReasonParamArrayIndexingInvalid indicates that the use of param array indexing is out of bound.
PipelineRunReasonParamArrayIndexingInvalid PipelineRunReason = "ParamArrayIndexingInvalid"
// ReasonCouldntGetTask indicates that the reason for the failure status is that the
// associated Pipeline's Tasks couldn't all be retrieved
Expand Down
67 changes: 0 additions & 67 deletions pkg/apis/pipeline/v1/pipelinerun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1415,38 +1415,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) {
name string
spec v1.PipelineSpec
}{{
name: "array indexing in Tasks",
spec: v1.PipelineSpec{
Params: []v1.ParamSpec{
{Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")},
},
Tasks: []v1.PipelineTask{{
Name: "foo",
Params: v1.Params{
{Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")},
},
TaskRef: &v1.TaskRef{Name: "foo"},
}},
},
}, {
name: "array indexing in Finally",
spec: v1.PipelineSpec{
Params: []v1.ParamSpec{
{Name: "first-param", Type: v1.ParamTypeArray, Default: v1.NewStructuredValues("default-value", "default-value-again")},
},
Tasks: []v1.PipelineTask{{
Name: "foo",
TaskRef: &v1.TaskRef{Name: "foo"},
}},
Finally: []v1.PipelineTask{{
Name: "bar",
Params: v1.Params{
{Name: "first-task-first-param", Value: *v1.NewStructuredValues("$(params.first-param[0])")},
},
TaskRef: &v1.TaskRef{Name: "bar"},
}},
},
}, {
name: "pipeline tasks - use of resolver",
spec: v1.PipelineSpec{
Tasks: []v1.PipelineTask{{
Expand Down Expand Up @@ -1523,41 +1491,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) {
}},
}},
},
}, {
name: "array results",
spec: v1.PipelineSpec{
Tasks: []v1.PipelineTask{{
Name: "valid-pipeline-task",
TaskRef: &v1.TaskRef{Name: "foo-task"},
}},
Results: []v1.PipelineResult{{Name: "my-array-result", Type: v1.ResultsTypeArray, Value: *v1.NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}},
},
}, {
name: "array results in Tasks",
spec: v1.PipelineSpec{
Tasks: []v1.PipelineTask{{
Name: "valid-pipeline-task",
TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{
Steps: []v1.Step{{Image: "busybox", Script: "echo hello"}},
Results: []v1.TaskResult{{Name: "my-array-result", Type: v1.ResultsTypeArray}},
}},
}},
},
}, {
name: "array results in Finally",
spec: v1.PipelineSpec{
Tasks: []v1.PipelineTask{{
Name: "valid-pipeline-task",
TaskRef: &v1.TaskRef{Name: "foo-task"},
}},
Finally: []v1.PipelineTask{{
Name: "valid-finally-task",
TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{
Steps: []v1.Step{{Image: "busybox", Script: "echo hello"}},
Results: []v1.TaskResult{{Name: "my-array-result", Type: v1.ResultsTypeArray}},
}},
}},
},
}, {
name: "object results",
spec: v1.PipelineSpec{
Expand Down
7 changes: 1 addition & 6 deletions pkg/apis/pipeline/v1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,13 @@ func (ts *TaskSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object type parameter", config.BetaAPIFields).ViaFieldIndex("params", i))
}
}
// Indexing into array parameters
arrayIndexParamRefs := ts.GetIndexingReferencesToArrayParams()
if len(arrayIndexParamRefs) != 0 {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "indexing into array parameters", config.BetaAPIFields))
}
// Array and object results
for i, result := range ts.Results {
switch result.Type {
case ResultsTypeObject:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i))
case ResultsTypeArray:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i))
// Stable feature
case ResultsTypeString:
default:
}
Expand Down
24 changes: 0 additions & 24 deletions pkg/apis/pipeline/v1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2007,18 +2007,6 @@ func TestTaskBetaFields(t *testing.T) {
name string
spec v1.TaskSpec
}{{
name: "array param indexing",
spec: v1.TaskSpec{
Params: []v1.ParamSpec{{Name: "foo", Type: v1.ParamTypeArray}},
Steps: []v1.Step{{
Name: "my-step",
Image: "my-image",
Script: `
#!/usr/bin/env bash
echo $(params.foo[1])`,
}},
},
}, {
name: "object params",
spec: v1.TaskSpec{
Params: []v1.ParamSpec{{Name: "foo", Type: v1.ParamTypeObject, Properties: map[string]v1.PropertySpec{"bar": {Type: v1.ParamTypeString}}}},
Expand All @@ -2030,18 +2018,6 @@ func TestTaskBetaFields(t *testing.T) {
echo $(params.foo.bar)`,
}},
},
}, {
name: "array results",
spec: v1.TaskSpec{
Results: []v1.TaskResult{{Name: "array-result", Type: v1.ResultsTypeArray}},
Steps: []v1.Step{{
Name: "my-step",
Image: "my-image",
Script: `
#!/usr/bin/env bash
echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`,
}},
},
}, {
name: "object results",
spec: v1.TaskSpec{
Expand Down
24 changes: 0 additions & 24 deletions pkg/apis/pipeline/v1/taskrun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,18 +904,6 @@ func TestTaskRunBetaFields(t *testing.T) {
name string
spec v1.TaskSpec
}{{
name: "array param indexing",
spec: v1.TaskSpec{
Params: []v1.ParamSpec{{Name: "foo", Type: v1.ParamTypeArray}},
Steps: []v1.Step{{
Name: "my-step",
Image: "my-image",
Script: `
#!/usr/bin/env bash
echo $(params.foo[1])`,
}},
},
}, {
name: "object params",
spec: v1.TaskSpec{
Params: []v1.ParamSpec{{Name: "foo", Type: v1.ParamTypeObject, Properties: map[string]v1.PropertySpec{"bar": {Type: v1.ParamTypeString}}}},
Expand All @@ -927,18 +915,6 @@ func TestTaskRunBetaFields(t *testing.T) {
echo $(params.foo.bar)`,
}},
},
}, {
name: "array results",
spec: v1.TaskSpec{
Results: []v1.TaskResult{{Name: "array-result", Type: v1.ResultsTypeArray}},
Steps: []v1.Step{{
Name: "my-step",
Image: "my-image",
Script: `
#!/usr/bin/env bash
echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`,
}},
},
}, {
name: "object results",
spec: v1.TaskSpec{
Expand Down
7 changes: 1 addition & 6 deletions pkg/apis/pipeline/v1beta1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,13 @@ func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object type parameter", config.BetaAPIFields).ViaFieldIndex("params", i))
}
}
// Indexing into array parameters
arrayParamIndexingRefs := ps.GetIndexingReferencesToArrayParams()
if len(arrayParamIndexingRefs) != 0 {
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "indexing into array parameters", config.BetaAPIFields))
}
// array and object results
for i, result := range ps.Results {
switch result.Type {
case ResultsTypeObject:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i))
case ResultsTypeArray:
errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i))
// Stable feature
case ResultsTypeString:
default:
}
Expand Down
Loading

0 comments on commit c998128

Please sign in to comment.