Skip to content

Commit 13d2685

Browse files
[TEP-0144] Add feature flag and doc placeholder
Part of [tektoncd#7270][tektoncd#7270]. In [TEP-0144][tep-0144] we proposed a new `enum` field to support built-in param input validation. This commit adds the feature flag `enable-param-enum` and documentation placeholder for the feature. /kind feature [tektoncd#7270]: tektoncd#7270 [tep-0144]: https://github.com/tektoncd/community/blob/main/teps/0144-param-enum.md
1 parent 8123d63 commit 13d2685

7 files changed

+51
-0
lines changed

config/config-feature-flags.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ data:
124124
# Setting this flag to "true" will enable the CEL evaluation in WhenExpression
125125
# This feature is in preview mode and not implemented yet. Please check #7244 for the updates.
126126
enable-cel-in-whenexpression: "false"
127+
# Setting this flag to "true" will enable the built-in param input validation via param enum.
128+
# NOTE (#7270): this feature is still under development and not yet functional.
129+
enable-param-enum: "false"

docs/pipelines.md

+7
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ spec:
269269
- "bar"
270270
```
271271

272+
#### Param enum
273+
> :seedling: **Specifying `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.
274+
275+
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
276+
277+
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Pipeline`.
278+
272279
## Adding `Tasks` to the `Pipeline`
273280

274281
Your `Pipeline` definition must reference at least one [`Task`](tasks.md).

docs/tasks.md

+7
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,13 @@ spec:
712712
- "--someotherflag"
713713
```
714714
715+
#### Param enum
716+
> :seedling: **Specifying `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.
717+
718+
> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed.
719+
720+
Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Task`.
721+
715722
### Specifying `Workspaces`
716723

717724
[`Workspaces`](workspaces.md#using-workspaces-in-tasks) allow you to specify

pkg/apis/config/feature_flags.go

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ const (
9696
EnableCELInWhenExpression = "enable-cel-in-whenexpression"
9797
// DefaultEnableCELInWhenExpression is the default value for EnableCELInWhenExpression
9898
DefaultEnableCELInWhenExpression = false
99+
// EnableParamEnum is the flag to enabled enum in params
100+
EnableParamEnum = "enable-param-enum"
101+
// DefaultEnableParamEnum is the default value for EnableParamEnum
102+
DefaultEnableParamEnum = false
99103

100104
disableAffinityAssistantKey = "disable-affinity-assistant"
101105
disableCredsInitKey = "disable-creds-init"
@@ -145,6 +149,7 @@ type FeatureFlags struct {
145149
SetSecurityContext bool
146150
Coschedule string
147151
EnableCELInWhenExpression bool
152+
EnableParamEnum bool
148153
}
149154

150155
// GetFeatureFlagsConfigName returns the name of the configmap containing all
@@ -220,6 +225,9 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
220225
if err := setFeature(EnableCELInWhenExpression, DefaultEnableCELInWhenExpression, &tc.EnableCELInWhenExpression); err != nil {
221226
return nil, err
222227
}
228+
if err := setFeature(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil {
229+
return nil, err
230+
}
223231
// Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if
224232
// enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of
225233
// each feature's individual flag.

pkg/apis/config/feature_flags_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
7474
SetSecurityContext: true,
7575
Coschedule: config.CoscheduleDisabled,
7676
EnableCELInWhenExpression: true,
77+
EnableParamEnum: true,
7778
},
7879
fileName: "feature-flags-all-flags-set",
7980
},
@@ -273,6 +274,9 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
273274
}, {
274275
fileName: "feature-flags-invalid-enable-cel-in-whenexpression",
275276
want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`,
277+
}, {
278+
fileName: "feature-flags-invalid-enable-param-enum",
279+
want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`,
276280
}} {
277281
t.Run(tc.fileName, func(t *testing.T) {
278282
cm := test.ConfigMapFromTestFile(t, tc.fileName)

pkg/apis/config/testdata/feature-flags-all-flags-set.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ data:
3333
set-security-context: "true"
3434
keep-pod-on-cancel: "true"
3535
enable-cel-in-whenexpression: "true"
36+
enable-param-enum: "true"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2023 The Tekton Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: feature-flags
19+
namespace: tekton-pipelines
20+
data:
21+
enable-param-enum: "invalid"

0 commit comments

Comments
 (0)