From fe47c9bc893a5c714a9ae026ea5f2b19a64f9a63 Mon Sep 17 00:00:00 2001 From: Yongxuan Zhang Date: Wed, 3 Jan 2024 22:15:33 +0000 Subject: [PATCH] TEP-0075(object params and results) promoted to stable Pipeline 0.46 introduced object params and results. This commit is promoting TEP-0075 to stable such that these features can be used by the task authors and pipeline authors in a cluster when enable-api-fields is alpha,beta or stable. Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com --- docs/additional-configs.md | 1 - docs/pipelineruns.md | 78 +++++++++---------- docs/pipelines.md | 8 +- docs/taskruns.md | 68 ++++++++-------- docs/tasks.md | 2 +- .../pipeline-object-param-and-result.yaml | 0 .../{beta => }/pipeline-object-results.yaml | 0 .../{beta => }/object-param-result.yaml | 0 .../pipeline/v1/container_validation_test.go | 18 ----- pkg/apis/pipeline/v1/pipeline_validation.go | 8 +- .../pipeline/v1/pipeline_validation_test.go | 72 ----------------- .../v1/pipelineref_validation_test.go | 18 ----- .../v1/pipelinerun_validation_test.go | 72 ----------------- pkg/apis/pipeline/v1/task_validation.go | 8 +- pkg/apis/pipeline/v1/task_validation_test.go | 25 ------ .../pipeline/v1/taskref_validation_test.go | 18 ----- pkg/apis/pipeline/v1/taskrun_validation.go | 5 -- .../pipeline/v1/taskrun_validation_test.go | 25 ------ .../v1beta1/container_validation_test.go | 18 ----- .../pipeline/v1beta1/pipeline_validation.go | 8 +- .../v1beta1/pipeline_validation_test.go | 72 ----------------- .../v1beta1/pipelineref_validation_test.go | 18 ----- .../v1beta1/pipelinerun_validation_test.go | 72 ----------------- pkg/apis/pipeline/v1beta1/task_validation.go | 8 +- .../pipeline/v1beta1/task_validation_test.go | 25 ------ .../v1beta1/taskref_validation_test.go | 18 ----- .../pipeline/v1beta1/taskrun_validation.go | 5 -- .../v1beta1/taskrun_validation_test.go | 25 ------ 28 files changed, 80 insertions(+), 615 deletions(-) rename examples/v1/pipelineruns/{beta => }/pipeline-object-param-and-result.yaml (100%) rename examples/v1/pipelineruns/{beta => }/pipeline-object-results.yaml (100%) rename examples/v1/taskruns/{beta => }/object-param-result.yaml (100%) diff --git a/docs/additional-configs.md b/docs/additional-configs.md index f6500cffed4..b568a76d9e1 100644 --- a/docs/additional-configs.md +++ b/docs/additional-configs.md @@ -334,7 +334,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` | | [Isolated `Step` & `Sidecar` `Workspaces`](./workspaces.md#isolated-workspaces) | [TEP-0029](https://github.com/tektoncd/community/blob/main/teps/0029-step-workspaces.md) | [v0.24.0](https://github.com/tektoncd/pipeline/releases/tag/v0.24.0) | [v0.50.0](https://github.com/tektoncd/pipeline/releases/tag/v0.50.0) | | diff --git a/docs/pipelineruns.md b/docs/pipelineruns.md index f308dcced8a..2e7224e55fd 100644 --- a/docs/pipelineruns.md +++ b/docs/pipelineruns.md @@ -19,7 +19,7 @@ weight: 204 - [Propagated Parameters](#propagated-parameters) - [Scope and Precedence](#scope-and-precedence) - [Default Values](#default-values) - - [Object Parameters](#object-parameters) + - [Object Parameters](#object-parameters) - [Specifying custom ServiceAccount credentials](#specifying-custom-serviceaccount-credentials) - [Mapping ServiceAccount credentials to Tasks](#mapping-serviceaccount-credentials-to-tasks) - [Specifying a Pod template](#specifying-a-pod-template) @@ -71,12 +71,12 @@ A `PipelineRun` definition supports the following fields: - [`params`](#specifying-parameters) - Specifies the desired execution parameters for the `Pipeline`. - [`serviceAccountName`](#specifying-custom-serviceaccount-credentials) - Specifies a `ServiceAccount` object that supplies specific execution credentials for the `Pipeline`. - - [`status`](#cancelling-a-pipelinerun) - Specifies options for cancelling a `PipelineRun`. + - [`status`](#cancelling-a-pipelinerun) - Specifies options for cancelling a `PipelineRun`. - [`taskRunSpecs`](#specifying-taskrunspecs) - Specifies a list of `PipelineRunTaskSpec` which allows for setting `ServiceAccountName`, [`Pod` template](./podtemplates.md), and `Metadata` for each task. This overrides the `Pod` template set for the entire `Pipeline`. - [`timeout`](#configuring-a-failure-timeout) - Specifies the timeout before the `PipelineRun` fails. `timeout` is deprecated and will eventually be removed, so consider using `timeouts` instead. - [`timeouts`](#configuring-a-failure-timeout) - Specifies the timeout before the `PipelineRun` fails. `timeouts` allows more granular timeout configuration, at the pipeline, tasks, and finally levels - [`podTemplate`](#specifying-a-pod-template) - Specifies a [`Pod` template](./podtemplates.md) to use as the basis for the configuration of the `Pod` that executes each `Task`. - - [`workspaces`](#specifying-workspaces) - Specifies a set of workspace bindings which must match the names of workspaces declared in the pipeline being used. + - [`workspaces`](#specifying-workspaces) - Specifies a set of workspace bindings which must match the names of workspaces declared in the pipeline being used. [kubernetes-overview]: https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/#required-fields @@ -233,7 +233,7 @@ spec: apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 kind: PipelineRun metadata: - name: pipelinerun + name: pipelinerun spec: pipelineRef: name: pipeline @@ -275,9 +275,9 @@ go through the complexity of checking each `Pipeline` and providing only the req > :seedling: **`enum` is an [alpha](additional-configs.md#alpha-features) feature.** The `enable-param-enum` feature flag must be set to `"true"` to enable this feature. -If a `Parameter` is guarded by `Enum` in the `Pipeline`, you can only provide `Parameter` values in the `PipelineRun` that are predefined in the `Param.Enum` in the `Pipeline`. The `PipelineRun` will fail with reason `InvalidParamValue` otherwise. +If a `Parameter` is guarded by `Enum` in the `Pipeline`, you can only provide `Parameter` values in the `PipelineRun` that are predefined in the `Param.Enum` in the `Pipeline`. The `PipelineRun` will fail with reason `InvalidParamValue` otherwise. -Tekton will also the validate the `param` values passed to any referenced `Tasks` (via `taskRef`) if `Enum` is specified for the `Task`. The `PipelineRun` will fail with reason `InvalidParamValue` if `Enum` validation is failed for any of the `PipelineTask`. +Tekton will also the validate the `param` values passed to any referenced `Tasks` (via `taskRef`) if `Enum` is specified for the `Task`. The `PipelineRun` will fail with reason `InvalidParamValue` if `Enum` validation is failed for any of the `PipelineTask`. You can also specify `Enum` in an embedded `Pipeline` in a `PipelineRun`. The same `Param` validation will be executed in this scenario. @@ -579,43 +579,41 @@ status: ##### Object Parameters -Object params is a [beta feature](./additional-configs.md#beta-features). - When using an inlined spec, object parameters from the parent `PipelineRun` will also be propagated to any inlined specs without needing to be explicitly defined. This allows authors to simplify specs by automatically propagating top-level parameters down to other inlined resources. When propagating object parameters, scope and precedence also holds as shown below. - + ```yaml -apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 -kind: PipelineRun +apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 +kind: PipelineRun metadata: - generateName: pipelinerun-object-param-result + generateName: pipelinerun-object-param-result spec: params: - - name: gitrepo - value: - url: abc.com - commit: sha123 - pipelineSpec: - tasks: - - name: task1 - params: - - name: gitrepo + - name: gitrepo + value: + url: abc.com + commit: sha123 + pipelineSpec: + tasks: + - name: task1 + params: + - name: gitrepo value: - branch: main - url: xyz.com + branch: main + url: xyz.com taskSpec: steps: - - name: write-result - image: bash - args: [ - "echo", - "--url=$(params.gitrepo.url)", + - name: write-result + image: bash + args: [ + "echo", + "--url=$(params.gitrepo.url)", "--commit=$(params.gitrepo.commit)", "--branch=$(params.gitrepo.branch)", - ] + ] ``` resolves to @@ -650,7 +648,7 @@ spec: - --commit=$(params.gitrepo.commit) - --branch=$(params.gitrepo.branch) image: bash - name: write-result + name: write-result status: completionTime: "2022-09-08T17:22:01Z" conditions: @@ -784,7 +782,7 @@ spec: args: - echo "1001" | tee $(results.uid.path) - name: show-uid - # params: + # params: # - name: uid # value: $(tasks.add-uid.results.uid) taskSpec: @@ -885,7 +883,7 @@ metadata: spec: pipelineRef: name: mypipeline - taskRunTemplate: + taskRunTemplate: podTemplate: securityContext: runAsNonRoot: true @@ -1006,7 +1004,7 @@ spec: name: pipeline-name taskRunSpecs: - pipelineTaskName: task-name - metadata: + metadata: annotations: vault.hashicorp.com/agent-inject-secret-foo: "/path/to/foo" vault.hashicorp.com/role: role-name @@ -1020,7 +1018,7 @@ spec: name: pipeline-name taskRunSpecs: - pipelineTaskName: task-name - metadata: + metadata: labels: app: cloudevent ``` @@ -1110,10 +1108,10 @@ spec: tasks: - name: fetch-secure-data # workspaces: - # - name: shared-data + # - name: shared-data taskSpec: # workspaces: - # - name: shared-data + # - name: shared-data steps: - name: fetch-and-write-secure image: ubuntu @@ -1121,12 +1119,12 @@ spec: echo hi >> $(workspaces.shared-data.path)/recipe.txt - name: print-the-recipe # workspaces: - # - name: shared-data + # - name: shared-data runAfter: - fetch-secure-data taskSpec: # workspaces: - # - name: shared-data + # - name: shared-data steps: - name: print-secrets image: ubuntu @@ -1259,7 +1257,7 @@ spec: - name: fetch-and-write image: ubuntu script: | - echo $(workspaces.shared-data.path) + echo $(workspaces.shared-data.path) --- apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 kind: PipelineRun @@ -1432,7 +1430,7 @@ If you set the timeout to 0, the `PipelineRun` fails immediately upon encounteri Your `PipelineRun`'s `status` field can contain the following fields: - Required: - - `status` - Most relevant, `status.conditions`, which contains the latest observations of the `PipelineRun`'s state. [See here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) for information on typical status properties. + - `status` - Most relevant, `status.conditions`, which contains the latest observations of the `PipelineRun`'s state. [See here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) for information on typical status properties. - `startTime` - The time at which the `PipelineRun` began executing, in [RFC3339](https://tools.ietf.org/html/rfc3339) format. - `completionTime` - The time at which the `PipelineRun` finished executing, in [RFC3339](https://tools.ietf.org/html/rfc3339) format. - [`pipelineSpec`](pipelines.md#configuring-a-pipeline) - The exact `PipelineSpec` used when starting the `PipelineRun`. diff --git a/docs/pipelines.md b/docs/pipelines.md index fe67e39fbf5..3ce6e029e7f 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -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`. @@ -1280,7 +1280,7 @@ Sharing `Results` between `Tasks` in a `Pipeline` happens via a `Result` and another receives it as a `Parameter` with a variable such as `$(tasks..results.)`. Pipeline support two new types of results and parameters: array `[]string` and object `map[string]string`. -Array and Object result is a beta feature and can be enabled by setting `enable-api-fields` to `alpha` or `beta`. +Array result is a beta feature and can be enabled by setting `enable-api-fields` to `alpha` or `beta`. | Result Type | Parameter Type | Specification | `enable-api-fields` | |-------------|----------------|--------------------------------------------------|---------------------| @@ -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, +Array result is a beta feature, see [`Array and Object Results` in a `PipelineRun`](../examples/v1/pipelineruns/beta/pipeline-emitting-results.yaml). ```yaml diff --git a/docs/taskruns.md b/docs/taskruns.md index eeae6d776c3..6db9c375f1b 100644 --- a/docs/taskruns.md +++ b/docs/taskruns.md @@ -304,10 +304,10 @@ status: reason: Succeeded status: "True" type: Succeeded - ... + ... steps: - container: step-default - ... + ... taskSpec: steps: - image: ubuntu @@ -317,8 +317,6 @@ status: ``` #### Propagated Object Parameters -Object params is a [beta feature](./additional-configs.md#beta-features). - When using an inlined `taskSpec`, object parameters from the parent `TaskRun` will be available to the `Task` without needing to be explicitly defined. @@ -438,13 +436,13 @@ spec: apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 kind: TaskRun metadata: - name: taskrun + name: taskrun spec: taskRef: name: task computeResources: requests: - cpu: 1 + cpu: 1 limits: cpu: 2 ``` @@ -524,21 +522,21 @@ workspaces down to other inlined resources. **Workspace substutions will only be made for `commands`, `args` and `script` fields of `steps`, `stepTemplates`, and `sidecars`.** ```yaml -apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 -kind: TaskRun +apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 +kind: TaskRun metadata: generateName: propagating-workspaces- spec: - taskSpec: - steps: - - name: simple-step - image: ubuntu - command: - - echo - args: + taskSpec: + steps: + - name: simple-step + image: ubuntu + command: + - echo + args: - $(workspaces.tr-workspace.path) - workspaces: - - emptyDir: {} + workspaces: + - emptyDir: {} name: tr-workspace ``` @@ -564,32 +562,32 @@ status: ##### Propagating Workspaces to Referenced Tasks -Workspaces can only be propagated to `embedded` task specs, not `referenced` Tasks. +Workspaces can only be propagated to `embedded` task specs, not `referenced` Tasks. ```yaml -apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 -kind: Task +apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 +kind: Task metadata: name: workspace-propagation spec: steps: - - name: simple-step - image: ubuntu - command: - - echo - args: + - name: simple-step + image: ubuntu + command: + - echo + args: - $(workspaces.tr-workspace.path) --- -apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 +apiVersion: tekton.dev/v1 # or tekton.dev/v1beta1 kind: TaskRun metadata: generateName: propagating-workspaces- spec: - taskRef: + taskRef: name: workspace-propagation - workspaces: - - emptyDir: {} - name: tr-workspace + workspaces: + - emptyDir: {} + name: tr-workspace ``` Upon execution, the above `TaskRun` will fail because the `Task` is referenced and workspace is not propagated. It must be explicitly defined in the `spec` of the defined `Task`. @@ -788,7 +786,7 @@ The `status` field defines the observed state of `TaskRun` ### The `status` field - Required: - `status` - The most relevant information about the TaskRun's state. This field includes: - - `status.conditions`, which contains the latest observations of the `TaskRun`'s state. [See here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) for information on typical status properties. + - `status.conditions`, which contains the latest observations of the `TaskRun`'s state. [See here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) for information on typical status properties. - `podName` - Name of the pod containing the containers responsible for executing this `task`'s `step`s. - `startTime` - The time at which the `TaskRun` began executing, conforms to [RFC3339](https://tools.ietf.org/html/rfc3339) format. - `completionTime` - The time at which the `TaskRun` finished executing, conforms to [RFC3339](https://tools.ietf.org/html/rfc3339) format. @@ -802,11 +800,11 @@ The `status` field defines the observed state of `TaskRun` - `featureFlags`: Identifies the feature flags used during the `TaskRun`. - `steps` - Contains the `state` of each `step` container. - `retriesStatus` - Contains the history of `TaskRun`'s `status` in case of a retry in order to keep record of failures. No `status` stored within `retriesStatus` will have any `date` within as it is redundant. - + - [`sidecars`](tasks.md#using-a-sidecar-in-a-task) - This field is a list. The list has one entry per `sidecar` in the manifest. Each entry represents the imageid of the corresponding sidecar. - `spanContext` - Contains tracing span context fields. - - + + ## Monitoring execution status @@ -860,7 +858,7 @@ False | TaskRunImagePullFailed | n/a When a `TaskRun` changes status, [events](events.md#taskruns) are triggered accordingly. -The name of the `Pod` owned by a `TaskRun` is univocally associated to the owning resource. +The name of the `Pod` owned by a `TaskRun` is univocally associated to the owning resource. If a `TaskRun` resource is deleted and created with the same name, the child `Pod` will be created with the same name as before. The base format of the name is `-pod`. The name may vary according to the logic of [`kmeta.ChildName`](https://pkg.go.dev/github.com/knative/pkg/kmeta#ChildName). In case of retries of a `TaskRun` diff --git a/docs/tasks.md b/docs/tasks.md index e6977d45956..82e6f97278b 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -860,7 +860,7 @@ The stored results can be used [at the `Task` level](./pipelines.md#passing-one- or [at the `Pipeline` level](./pipelines.md#emitting-results-from-a-pipeline). #### Emitting Object `Results` -Emitting a task result of type `object` is a `beta` feature implemented based on the +Emitting a task result of type `object` is implemented based on the [TEP-0075](https://github.com/tektoncd/community/blob/main/teps/0075-object-param-and-result-types.md#emitting-object-results). You can initialize `object` results from a `task` using JSON escaped string. For example, to assign the following data to an object result: diff --git a/examples/v1/pipelineruns/beta/pipeline-object-param-and-result.yaml b/examples/v1/pipelineruns/pipeline-object-param-and-result.yaml similarity index 100% rename from examples/v1/pipelineruns/beta/pipeline-object-param-and-result.yaml rename to examples/v1/pipelineruns/pipeline-object-param-and-result.yaml diff --git a/examples/v1/pipelineruns/beta/pipeline-object-results.yaml b/examples/v1/pipelineruns/pipeline-object-results.yaml similarity index 100% rename from examples/v1/pipelineruns/beta/pipeline-object-results.yaml rename to examples/v1/pipelineruns/pipeline-object-results.yaml diff --git a/examples/v1/taskruns/beta/object-param-result.yaml b/examples/v1/taskruns/object-param-result.yaml similarity index 100% rename from examples/v1/taskruns/beta/object-param-result.yaml rename to examples/v1/taskruns/object-param-result.yaml diff --git a/pkg/apis/pipeline/v1/container_validation_test.go b/pkg/apis/pipeline/v1/container_validation_test.go index f9556a468a1..60c95f88120 100644 --- a/pkg/apis/pipeline/v1/container_validation_test.go +++ b/pkg/apis/pipeline/v1/container_validation_test.go @@ -123,24 +123,6 @@ func TestRef_Invalid(t *testing.T) { Message: `invalid value: name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')`, Paths: []string{"name"}, }, - }, { - name: "ref param object requires beta", - ref: &v1.Ref{ - ResolverRef: v1.ResolverRef{ - Resolver: "some-resolver", - Params: v1.Params{{ - Name: "foo", - Value: v1.ParamValue{ - Type: v1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/pipeline_validation.go b/pkg/apis/pipeline/v1/pipeline_validation.go index 2dc3b884f7d..9c000c673e8 100644 --- a/pkg/apis/pipeline/v1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1/pipeline_validation.go @@ -94,12 +94,6 @@ func (ps *PipelineSpec) Validate(ctx context.Context) (errs *apis.FieldError) { // have "enable-api-fields" set to "alpha" or "beta". func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - // Object parameters - for i, p := range ps.Params { - if p.Type == ParamTypeObject { - 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 { @@ -109,7 +103,7 @@ func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError for i, result := range ps.Results { switch result.Type { case ResultsTypeObject: - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i)) + // stable feature case ResultsTypeArray: errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i)) case ResultsTypeString: diff --git a/pkg/apis/pipeline/v1/pipeline_validation_test.go b/pkg/apis/pipeline/v1/pipeline_validation_test.go index 37d7100bc56..cf7344a7b35 100644 --- a/pkg/apis/pipeline/v1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1/pipeline_validation_test.go @@ -4221,43 +4221,6 @@ func TestPipelineWithBetaFields(t *testing.T) { TaskRef: &TaskRef{ResolverRef: ResolverRef{Resolver: "bar", Params: Params{{}}}}, }}, }, - }, { - name: "object params", - spec: PipelineSpec{ - Params: []ParamSpec{ - {Name: "first-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}, - }, - Tasks: []PipelineTask{{ - Name: "foo", - TaskRef: &TaskRef{Name: "foo"}, - }}, - }, - }, { - name: "object params in Tasks", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "valid-pipeline-task", - TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{ - Steps: []Step{{Image: "busybox", Script: "echo hello"}}, - Params: []ParamSpec{{Name: "my-object-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object params in Finally", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "foo", - TaskRef: &TaskRef{Name: "foo"}, - }}, - Finally: []PipelineTask{{ - Name: "valid-finally-task", - TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{ - Steps: []Step{{Image: "busybox", Script: "echo hello"}}, - Params: []ParamSpec{{Name: "my-object-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, }, { name: "array results", spec: PipelineSpec{ @@ -4293,41 +4256,6 @@ func TestPipelineWithBetaFields(t *testing.T) { }}, }}, }, - }, { - name: "object results", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "valid-pipeline-task", - TaskRef: &TaskRef{Name: "foo-task"}, - }}, - Results: []PipelineResult{{Name: "my-object-result", Type: ResultsTypeObject, Value: *NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}}, - }, - }, { - name: "object 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-object-result", Type: ResultsTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object 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-object-result", Type: ResultsTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, }} for _, tt := range tts { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/pipelineref_validation_test.go b/pkg/apis/pipeline/v1/pipelineref_validation_test.go index 7f8057985b9..114eb6a0f10 100644 --- a/pkg/apis/pipeline/v1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1/pipelineref_validation_test.go @@ -90,24 +90,6 @@ func TestPipelineRef_Invalid(t *testing.T) { }, wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), withContext: cfgtesting.EnableBetaAPIFields, - }, { - name: "pipelineref param object not allowed in stable", - ref: &v1.PipelineRef{ - ResolverRef: v1.ResolverRef{ - Resolver: "some-resolver", - Params: v1.Params{{ - Name: "foo", - Value: v1.ParamValue{ - Type: v1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), - withContext: cfgtesting.EnableStableAPIFields, }} for _, tc := range tests { diff --git a/pkg/apis/pipeline/v1/pipelinerun_validation_test.go b/pkg/apis/pipeline/v1/pipelinerun_validation_test.go index 6ebff9a9bba..f6862bb7357 100644 --- a/pkg/apis/pipeline/v1/pipelinerun_validation_test.go +++ b/pkg/apis/pipeline/v1/pipelinerun_validation_test.go @@ -1486,43 +1486,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) { TaskRef: &v1.TaskRef{ResolverRef: v1.ResolverRef{Resolver: "bar", Params: v1.Params{{}}}}, }}, }, - }, { - name: "object params", - spec: v1.PipelineSpec{ - Params: []v1.ParamSpec{ - {Name: "first-param", Type: v1.ParamTypeObject, Properties: map[string]v1.PropertySpec{}}, - }, - Tasks: []v1.PipelineTask{{ - Name: "foo", - TaskRef: &v1.TaskRef{Name: "foo"}, - }}, - }, - }, { - name: "object params 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"}}, - Params: []v1.ParamSpec{{Name: "my-object-param", Type: v1.ParamTypeObject, Properties: map[string]v1.PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object params in Finally", - spec: v1.PipelineSpec{ - Tasks: []v1.PipelineTask{{ - Name: "foo", - TaskRef: &v1.TaskRef{Name: "foo"}, - }}, - Finally: []v1.PipelineTask{{ - Name: "valid-finally-task", - TaskSpec: &v1.EmbeddedTask{TaskSpec: v1.TaskSpec{ - Steps: []v1.Step{{Image: "busybox", Script: "echo hello"}}, - Params: []v1.ParamSpec{{Name: "my-object-param", Type: v1.ParamTypeObject, Properties: map[string]v1.PropertySpec{}}}, - }}, - }}, - }, }, { name: "array results", spec: v1.PipelineSpec{ @@ -1558,41 +1521,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) { }}, }}, }, - }, { - name: "object results", - spec: v1.PipelineSpec{ - Tasks: []v1.PipelineTask{{ - Name: "valid-pipeline-task", - TaskRef: &v1.TaskRef{Name: "foo-task"}, - }}, - Results: []v1.PipelineResult{{Name: "my-object-result", Type: v1.ResultsTypeObject, Value: *v1.NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}}, - }, - }, { - name: "object 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-object-result", Type: v1.ResultsTypeObject, Properties: map[string]v1.PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object 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-object-result", Type: v1.ResultsTypeObject, Properties: map[string]v1.PropertySpec{}}}, - }}, - }}, - }, }} for _, tt := range tts { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/task_validation.go b/pkg/apis/pipeline/v1/task_validation.go index 38b316dc7a2..23f7178645e 100644 --- a/pkg/apis/pipeline/v1/task_validation.go +++ b/pkg/apis/pipeline/v1/task_validation.go @@ -102,12 +102,6 @@ func (ts *TaskSpec) Validate(ctx context.Context) (errs *apis.FieldError) { // have "enable-api-fields" set to "alpha" or "beta". func (ts *TaskSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - // Object parameters - for i, p := range ts.Params { - if p.Type == ParamTypeObject { - 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 { @@ -117,7 +111,7 @@ func (ts *TaskSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { for i, result := range ts.Results { switch result.Type { case ResultsTypeObject: - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i)) + // stable feature case ResultsTypeArray: errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i)) case ResultsTypeString: diff --git a/pkg/apis/pipeline/v1/task_validation_test.go b/pkg/apis/pipeline/v1/task_validation_test.go index 0786a0171c3..27a830faa54 100644 --- a/pkg/apis/pipeline/v1/task_validation_test.go +++ b/pkg/apis/pipeline/v1/task_validation_test.go @@ -2018,18 +2018,6 @@ func TestTaskBetaFields(t *testing.T) { 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}}}}, - Steps: []v1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo $(params.foo.bar)`, - }}, - }, }, { name: "array results", spec: v1.TaskSpec{ @@ -2042,19 +2030,6 @@ func TestTaskBetaFields(t *testing.T) { echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`, }}, }, - }, { - name: "object results", - spec: v1.TaskSpec{ - Results: []v1.TaskResult{{Name: "object-result", Type: v1.ResultsTypeObject, - Properties: map[string]v1.PropertySpec{}}}, - Steps: []v1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo -n "{\"hello\":\"world\"}" | tee $(results.object-result.path)`, - }}, - }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/taskref_validation_test.go b/pkg/apis/pipeline/v1/taskref_validation_test.go index 946f2b4ae2c..d2c721bc6a1 100644 --- a/pkg/apis/pipeline/v1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1/taskref_validation_test.go @@ -145,24 +145,6 @@ func TestTaskRef_Invalid(t *testing.T) { }, wantErr: apis.ErrMultipleOneOf("name", "params").Also(apis.ErrMissingField("resolver")), wc: cfgtesting.EnableBetaAPIFields, - }, { - name: "taskref param object requires beta", - taskRef: &v1.TaskRef{ - ResolverRef: v1.ResolverRef{ - Resolver: "some-resolver", - Params: v1.Params{{ - Name: "foo", - Value: v1.ParamValue{ - Type: v1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1/taskrun_validation.go b/pkg/apis/pipeline/v1/taskrun_validation.go index b9495138fc4..e9bf1c17f6e 100644 --- a/pkg/apis/pipeline/v1/taskrun_validation.go +++ b/pkg/apis/pipeline/v1/taskrun_validation.go @@ -237,11 +237,6 @@ func ValidateWorkspaceBindings(ctx context.Context, wb []WorkspaceBinding) (errs func ValidateParameters(ctx context.Context, params Params) (errs *apis.FieldError) { var names []string for _, p := range params { - if p.Value.Type == ParamTypeObject { - // Object type parameter is a beta feature and will fail validation if it's used in a taskrun spec - // when the enable-api-fields feature gate is not "alpha" or "beta". - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object type parameter", config.BetaAPIFields)) - } names = append(names, p.Name) } return errs.Also(validateNoDuplicateNames(names, false)) diff --git a/pkg/apis/pipeline/v1/taskrun_validation_test.go b/pkg/apis/pipeline/v1/taskrun_validation_test.go index c895cbe5834..06a99b840df 100644 --- a/pkg/apis/pipeline/v1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1/taskrun_validation_test.go @@ -915,18 +915,6 @@ func TestTaskRunBetaFields(t *testing.T) { 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}}}}, - Steps: []v1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo $(params.foo.bar)`, - }}, - }, }, { name: "array results", spec: v1.TaskSpec{ @@ -939,19 +927,6 @@ func TestTaskRunBetaFields(t *testing.T) { echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`, }}, }, - }, { - name: "object results", - spec: v1.TaskSpec{ - Results: []v1.TaskResult{{Name: "object-result", Type: v1.ResultsTypeObject, - Properties: map[string]v1.PropertySpec{}}}, - Steps: []v1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo -n "{\"hello\":\"world\"}" | tee $(results.object-result.path)`, - }}, - }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/container_validation_test.go b/pkg/apis/pipeline/v1beta1/container_validation_test.go index fa395734bc8..95e7e4a28c0 100644 --- a/pkg/apis/pipeline/v1beta1/container_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/container_validation_test.go @@ -123,24 +123,6 @@ func TestRef_Invalid(t *testing.T) { Message: `invalid value: name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')`, Paths: []string{"name"}, }, - }, { - name: "ref param object requires beta", - ref: &v1beta1.Ref{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "some-resolver", - Params: v1beta1.Params{{ - Name: "foo", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation.go b/pkg/apis/pipeline/v1beta1/pipeline_validation.go index 7ee9ba354ed..69d39e09546 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation.go @@ -97,12 +97,6 @@ func (ps *PipelineSpec) Validate(ctx context.Context) (errs *apis.FieldError) { // `enable-api-fields` but does not have "enable-api-fields" set to "alpha" or "beta". func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - // Object parameters - for i, p := range ps.Params { - if p.Type == ParamTypeObject { - 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 { @@ -112,7 +106,7 @@ func (ps *PipelineSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError for i, result := range ps.Results { switch result.Type { case ResultsTypeObject: - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i)) + // stable feature case ResultsTypeArray: errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i)) case ResultsTypeString: diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go index 3de8912aa1f..01d6995f668 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go @@ -4283,43 +4283,6 @@ func TestPipelineWithBetaFields(t *testing.T) { TaskRef: &TaskRef{ResolverRef: ResolverRef{Resolver: "bar", Params: Params{{}}}}, }}, }, - }, { - name: "object params", - spec: PipelineSpec{ - Params: []ParamSpec{ - {Name: "first-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}, - }, - Tasks: []PipelineTask{{ - Name: "foo", - TaskRef: &TaskRef{Name: "foo"}, - }}, - }, - }, { - name: "object params in Tasks", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "valid-pipeline-task", - TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{ - Steps: []Step{{Image: "busybox", Script: "echo hello"}}, - Params: []ParamSpec{{Name: "my-object-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object params in Finally", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "foo", - TaskRef: &TaskRef{Name: "foo"}, - }}, - Finally: []PipelineTask{{ - Name: "valid-finally-task", - TaskSpec: &EmbeddedTask{TaskSpec: TaskSpec{ - Steps: []Step{{Image: "busybox", Script: "echo hello"}}, - Params: []ParamSpec{{Name: "my-object-param", Type: ParamTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, }, { name: "array results", spec: PipelineSpec{ @@ -4355,41 +4318,6 @@ func TestPipelineWithBetaFields(t *testing.T) { }}, }}, }, - }, { - name: "object results", - spec: PipelineSpec{ - Tasks: []PipelineTask{{ - Name: "valid-pipeline-task", - TaskRef: &TaskRef{Name: "foo-task"}, - }}, - Results: []PipelineResult{{Name: "my-object-result", Type: ResultsTypeObject, Value: *NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}}, - }, - }, { - name: "object 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-object-result", Type: ResultsTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object 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-object-result", Type: ResultsTypeObject, Properties: map[string]PropertySpec{}}}, - }}, - }}, - }, }} for _, tt := range tts { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go index 075dafcfe5e..82549d20ca9 100644 --- a/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelineref_validation_test.go @@ -142,24 +142,6 @@ func TestPipelineRef_Invalid(t *testing.T) { }, wantErr: apis.ErrMultipleOneOf("bundle", "params").Also(apis.ErrMissingField("resolver")), withContext: enableTektonOCIBundles(t), - }, { - name: "pipelineref param object not allowed in stable", - ref: &v1beta1.PipelineRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "some-resolver", - Params: v1beta1.Params{{ - Name: "foo", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), - withContext: cfgtesting.EnableStableAPIFields, }} for _, tc := range tests { diff --git a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go index d0666d019a4..7b0a9794fae 100644 --- a/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipelinerun_validation_test.go @@ -1637,43 +1637,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) { TaskRef: &v1beta1.TaskRef{ResolverRef: v1beta1.ResolverRef{Resolver: "bar", Params: v1beta1.Params{{}}}}, }}, }, - }, { - name: "object params", - spec: v1beta1.PipelineSpec{ - Params: []v1beta1.ParamSpec{ - {Name: "first-param", Type: v1beta1.ParamTypeObject, Properties: map[string]v1beta1.PropertySpec{}}, - }, - Tasks: []v1beta1.PipelineTask{{ - Name: "foo", - TaskRef: &v1beta1.TaskRef{Name: "foo"}, - }}, - }, - }, { - name: "object params in Tasks", - spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Name: "valid-pipeline-task", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{Image: "busybox", Script: "echo hello"}}, - Params: []v1beta1.ParamSpec{{Name: "my-object-param", Type: v1beta1.ParamTypeObject, Properties: map[string]v1beta1.PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object params in Finally", - spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Name: "foo", - TaskRef: &v1beta1.TaskRef{Name: "foo"}, - }}, - Finally: []v1beta1.PipelineTask{{ - Name: "valid-finally-task", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{Image: "busybox", Script: "echo hello"}}, - Params: []v1beta1.ParamSpec{{Name: "my-object-param", Type: v1beta1.ParamTypeObject, Properties: map[string]v1beta1.PropertySpec{}}}, - }}, - }}, - }, }, { name: "array results", spec: v1beta1.PipelineSpec{ @@ -1709,41 +1672,6 @@ func TestPipelineRunSpecBetaFeatures(t *testing.T) { }}, }}, }, - }, { - name: "object results", - spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Name: "valid-pipeline-task", - TaskRef: &v1beta1.TaskRef{Name: "foo-task"}, - }}, - Results: []v1beta1.PipelineResult{{Name: "my-object-result", Type: v1beta1.ResultsTypeObject, Value: *v1beta1.NewStructuredValues("$(tasks.valid-pipeline-task.results.foo[*])")}}, - }, - }, { - name: "object results in Tasks", - spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Name: "valid-pipeline-task", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{Image: "busybox", Script: "echo hello"}}, - Results: []v1beta1.TaskResult{{Name: "my-object-result", Type: v1beta1.ResultsTypeObject, Properties: map[string]v1beta1.PropertySpec{}}}, - }}, - }}, - }, - }, { - name: "object results in Finally", - spec: v1beta1.PipelineSpec{ - Tasks: []v1beta1.PipelineTask{{ - Name: "valid-pipeline-task", - TaskRef: &v1beta1.TaskRef{Name: "foo-task"}, - }}, - Finally: []v1beta1.PipelineTask{{ - Name: "valid-finally-task", - TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{ - Steps: []v1beta1.Step{{Image: "busybox", Script: "echo hello"}}, - Results: []v1beta1.TaskResult{{Name: "my-object-result", Type: v1beta1.ResultsTypeObject, Properties: map[string]v1beta1.PropertySpec{}}}, - }}, - }}, - }, }} for _, tt := range tts { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/task_validation.go b/pkg/apis/pipeline/v1beta1/task_validation.go index 95ddbc1f6d4..c9a5e5a9ec9 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation.go +++ b/pkg/apis/pipeline/v1beta1/task_validation.go @@ -105,12 +105,6 @@ func (ts *TaskSpec) Validate(ctx context.Context) (errs *apis.FieldError) { // `enable-api-fields` but does not have "enable-api-fields" set to "alpha" or "beta". func (ts *TaskSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { var errs *apis.FieldError - // Object parameters - for i, p := range ts.Params { - if p.Type == ParamTypeObject { - 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 { @@ -120,7 +114,7 @@ func (ts *TaskSpec) ValidateBetaFields(ctx context.Context) *apis.FieldError { for i, result := range ts.Results { switch result.Type { case ResultsTypeObject: - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object results", config.BetaAPIFields).ViaFieldIndex("results", i)) + // stable feature case ResultsTypeArray: errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "array results", config.BetaAPIFields).ViaFieldIndex("results", i)) case ResultsTypeString: diff --git a/pkg/apis/pipeline/v1beta1/task_validation_test.go b/pkg/apis/pipeline/v1beta1/task_validation_test.go index 9e89ee83fbd..bee77c71b69 100644 --- a/pkg/apis/pipeline/v1beta1/task_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/task_validation_test.go @@ -1980,18 +1980,6 @@ func TestTaskBetaFields(t *testing.T) { echo $(params.foo[1])`, }}, }, - }, { - name: "object params", - spec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{Name: "foo", Type: v1beta1.ParamTypeObject, Properties: map[string]v1beta1.PropertySpec{"bar": {Type: v1beta1.ParamTypeString}}}}, - Steps: []v1beta1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo $(params.foo.bar)`, - }}, - }, }, { name: "array results", spec: v1beta1.TaskSpec{ @@ -2004,19 +1992,6 @@ func TestTaskBetaFields(t *testing.T) { echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`, }}, }, - }, { - name: "object results", - spec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{Name: "object-result", Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{}}}, - Steps: []v1beta1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo -n "{\"hello\":\"world\"}" | tee $(results.object-result.path)`, - }}, - }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go index 8ec39f75fa9..7d1f4f488ff 100644 --- a/pkg/apis/pipeline/v1beta1/taskref_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskref_validation_test.go @@ -177,24 +177,6 @@ func TestTaskRef_Invalid(t *testing.T) { Message: `invalid value: name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')`, Paths: []string{"name"}, }, - }, { - name: "taskref param object requires beta", - taskRef: &v1beta1.TaskRef{ - ResolverRef: v1beta1.ResolverRef{ - Resolver: "some-resolver", - Params: v1beta1.Params{{ - Name: "foo", - Value: v1beta1.ParamValue{ - Type: v1beta1.ParamTypeObject, - ObjectVal: map[string]string{"bar": "baz"}, - }, - }}, - }, - }, - wc: cfgtesting.EnableStableAPIFields, - wantErr: apis.ErrGeneric("resolver requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"").Also( - apis.ErrGeneric("resolver params requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")).Also( - apis.ErrGeneric("object type parameter requires \"enable-api-fields\" feature gate to be \"alpha\" or \"beta\" but it is \"stable\"")), }} for _, ts := range tests { t.Run(ts.name, func(t *testing.T) { diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation.go b/pkg/apis/pipeline/v1beta1/taskrun_validation.go index 0baf7dfc7ab..e5108a6464c 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation.go @@ -239,11 +239,6 @@ func ValidateWorkspaceBindings(ctx context.Context, wb []WorkspaceBinding) (errs func ValidateParameters(ctx context.Context, params Params) (errs *apis.FieldError) { var names []string for _, p := range params { - if p.Value.Type == ParamTypeObject { - // Object type parameter is a beta feature and will fail validation if it's used in a taskrun spec - // when the enable-api-fields feature gate is not "alpha" or "beta". - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "object type parameter", config.BetaAPIFields)) - } names = append(names, p.Name) } return errs.Also(validateNoDuplicateNames(names, false)) diff --git a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go index 3207331b0fd..4020f293ba6 100644 --- a/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/taskrun_validation_test.go @@ -921,18 +921,6 @@ func TestTaskRunBetaFields(t *testing.T) { echo $(params.foo[1])`, }}, }, - }, { - name: "object params", - spec: v1beta1.TaskSpec{ - Params: []v1beta1.ParamSpec{{Name: "foo", Type: v1beta1.ParamTypeObject, Properties: map[string]v1beta1.PropertySpec{"bar": {Type: v1beta1.ParamTypeString}}}}, - Steps: []v1beta1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo $(params.foo.bar)`, - }}, - }, }, { name: "array results", spec: v1beta1.TaskSpec{ @@ -945,19 +933,6 @@ func TestTaskRunBetaFields(t *testing.T) { echo -n "[\"hello\",\"world\"]" | tee $(results.array-result.path)`, }}, }, - }, { - name: "object results", - spec: v1beta1.TaskSpec{ - Results: []v1beta1.TaskResult{{Name: "object-result", Type: v1beta1.ResultsTypeObject, - Properties: map[string]v1beta1.PropertySpec{}}}, - Steps: []v1beta1.Step{{ - Name: "my-step", - Image: "my-image", - Script: ` - #!/usr/bin/env bash - echo -n "{\"hello\":\"world\"}" | tee $(results.object-result.path)`, - }}, - }, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {