Skip to content

Commit b9df1f6

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 08ee164 commit b9df1f6

7 files changed

+51
-0
lines changed

config/config-feature-flags.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ data:
127127
# Setting this flag to "true" will enable the use of StepActions in Steps
128128
# This feature is in preview mode and not implemented yet. Please check #7259 for updates.
129129
enable-step-actions: "false"
130+
# Setting this flag to "true" will enable the built-in param input validation via param enum.
131+
# NOTE (#7270): this feature is still under development and not yet functional.
132+
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
@@ -100,6 +100,10 @@ const (
100100
EnableStepActions = "enable-step-actions"
101101
// DefaultEnableStepActions is the default value for EnableStepActions
102102
DefaultEnableStepActions = false
103+
// EnableParamEnum is the flag to enabled enum in params
104+
EnableParamEnum = "enable-param-enum"
105+
// DefaultEnableParamEnum is the default value for EnableParamEnum
106+
DefaultEnableParamEnum = false
103107

104108
disableAffinityAssistantKey = "disable-affinity-assistant"
105109
disableCredsInitKey = "disable-creds-init"
@@ -150,6 +154,7 @@ type FeatureFlags struct {
150154
Coschedule string
151155
EnableCELInWhenExpression bool
152156
EnableStepActions bool
157+
EnableParamEnum bool
153158
}
154159

155160
// GetFeatureFlagsConfigName returns the name of the configmap containing all
@@ -228,6 +233,9 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
228233
if err := setFeature(EnableStepActions, DefaultEnableStepActions, &tc.EnableStepActions); err != nil {
229234
return nil, err
230235
}
236+
if err := setFeature(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil {
237+
return nil, err
238+
}
231239
// Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if
232240
// enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of
233241
// each feature's individual flag.

pkg/apis/config/feature_flags_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) {
7575
Coschedule: config.CoscheduleDisabled,
7676
EnableCELInWhenExpression: true,
7777
EnableStepActions: true,
78+
EnableParamEnum: true,
7879
},
7980
fileName: "feature-flags-all-flags-set",
8081
},
@@ -277,6 +278,9 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) {
277278
}, {
278279
fileName: "feature-flags-invalid-enable-step-actions",
279280
want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`,
281+
}, {
282+
fileName: "feature-flags-invalid-enable-param-enum",
283+
want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`,
280284
}} {
281285
t.Run(tc.fileName, func(t *testing.T) {
282286
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
@@ -34,3 +34,4 @@ data:
3434
keep-pod-on-cancel: "true"
3535
enable-cel-in-whenexpression: "true"
3636
enable-step-actions: "true"
37+
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)