From e4b43a976557382df1710c619f7a11304bfbb7b9 Mon Sep 17 00:00:00 2001 From: Quan Zhang Date: Tue, 24 Oct 2023 15:38:17 -0400 Subject: [PATCH] [TEP-0144] Add feature flag and doc placeholder Part of [#7270][#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 [#7270]: https://github.com/tektoncd/pipeline/issues/7270 [tep-0144]: https://github.com/tektoncd/community/blob/main/teps/0144-param-enum.md --- config/config-feature-flags.yaml | 6 ++++++ docs/pipelines.md | 7 +++++++ docs/tasks.md | 7 +++++++ pkg/apis/config/feature_flags.go | 12 +++++++++++ pkg/apis/config/feature_flags_test.go | 7 +++++++ .../testdata/feature-flags-all-flags-set.yaml | 1 + ...ature-flags-invalid-enable-param-enum.yaml | 21 +++++++++++++++++++ 7 files changed, 61 insertions(+) create mode 100644 pkg/apis/config/testdata/feature-flags-invalid-enable-param-enum.yaml diff --git a/config/config-feature-flags.yaml b/config/config-feature-flags.yaml index a49d26ccb78..ce631d34a4a 100644 --- a/config/config-feature-flags.yaml +++ b/config/config-feature-flags.yaml @@ -124,6 +124,12 @@ data: # Setting this flag to "true" will enable the CEL evaluation in WhenExpression # This feature is in preview mode and not implemented yet. Please check #7244 for the updates. enable-cel-in-whenexpression: "false" +<<<<<<< HEAD # Setting this flag to "true" will enable the use of StepActions in Steps # This feature is in preview mode and not implemented yet. Please check #7259 for updates. enable-step-actions: "false" +======= + # Setting this flag to "true" will enable the built-in param input validation via param enum. + # NOTE (#7270): this feature is still under development and not yet functional. + enable-param-enum: "false" +>>>>>>> 13d26851f ([TEP-0144] Add feature flag and doc placeholder) diff --git a/docs/pipelines.md b/docs/pipelines.md index 44071ab5a3a..14d2ca58aae 100644 --- a/docs/pipelines.md +++ b/docs/pipelines.md @@ -269,6 +269,13 @@ spec: - "bar" ``` +#### Param enum +> :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. + +> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed. + +Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Pipeline`. + ## Adding `Tasks` to the `Pipeline` Your `Pipeline` definition must reference at least one [`Task`](tasks.md). diff --git a/docs/tasks.md b/docs/tasks.md index d5259d87a3d..09576bb6634 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -712,6 +712,13 @@ spec: - "--someotherflag" ``` +#### Param enum +> :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. + +> :seedling: This feature is WIP and not yet supported/implemented. Documentation to be completed. + +Parameter declarations can include `enum` which is a predefine set of valid values that can be accepted by the `Task`. + ### Specifying `Workspaces` [`Workspaces`](workspaces.md#using-workspaces-in-tasks) allow you to specify diff --git a/pkg/apis/config/feature_flags.go b/pkg/apis/config/feature_flags.go index 656de7c8a93..6b5484f5761 100644 --- a/pkg/apis/config/feature_flags.go +++ b/pkg/apis/config/feature_flags.go @@ -100,6 +100,10 @@ const ( EnableStepActions = "enable-step-actions" // DefaultEnableStepActions is the default value for EnableStepActions DefaultEnableStepActions = false + // EnableParamEnum is the flag to enabled enum in params + EnableParamEnum = "enable-param-enum" + // DefaultEnableParamEnum is the default value for EnableParamEnum + DefaultEnableParamEnum = false disableAffinityAssistantKey = "disable-affinity-assistant" disableCredsInitKey = "disable-creds-init" @@ -149,7 +153,11 @@ type FeatureFlags struct { SetSecurityContext bool Coschedule string EnableCELInWhenExpression bool +<<<<<<< HEAD EnableStepActions bool +======= + EnableParamEnum bool +>>>>>>> 13d26851f ([TEP-0144] Add feature flag and doc placeholder) } // GetFeatureFlagsConfigName returns the name of the configmap containing all @@ -225,7 +233,11 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { if err := setFeature(EnableCELInWhenExpression, DefaultEnableCELInWhenExpression, &tc.EnableCELInWhenExpression); err != nil { return nil, err } +<<<<<<< HEAD if err := setFeature(EnableStepActions, DefaultEnableStepActions, &tc.EnableStepActions); err != nil { +======= + if err := setFeature(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil { +>>>>>>> 13d26851f ([TEP-0144] Add feature flag and doc placeholder) return nil, err } // Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if diff --git a/pkg/apis/config/feature_flags_test.go b/pkg/apis/config/feature_flags_test.go index afa954c8d4d..1c3dcad0213 100644 --- a/pkg/apis/config/feature_flags_test.go +++ b/pkg/apis/config/feature_flags_test.go @@ -74,7 +74,11 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { SetSecurityContext: true, Coschedule: config.CoscheduleDisabled, EnableCELInWhenExpression: true, +<<<<<<< HEAD EnableStepActions: true, +======= + EnableParamEnum: true, +>>>>>>> 13d26851f ([TEP-0144] Add feature flag and doc placeholder) }, fileName: "feature-flags-all-flags-set", }, @@ -277,6 +281,9 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) { }, { fileName: "feature-flags-invalid-enable-step-actions", want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`, + }, { + fileName: "feature-flags-invalid-enable-param-enum", + want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`, }} { t.Run(tc.fileName, func(t *testing.T) { cm := test.ConfigMapFromTestFile(t, tc.fileName) diff --git a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml index bf087e8a427..349527d4125 100644 --- a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml +++ b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml @@ -34,3 +34,4 @@ data: keep-pod-on-cancel: "true" enable-cel-in-whenexpression: "true" enable-step-actions: "true" + enable-param-enum: "true" diff --git a/pkg/apis/config/testdata/feature-flags-invalid-enable-param-enum.yaml b/pkg/apis/config/testdata/feature-flags-invalid-enable-param-enum.yaml new file mode 100644 index 00000000000..b101896d0b4 --- /dev/null +++ b/pkg/apis/config/testdata/feature-flags-invalid-enable-param-enum.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 The Tekton Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: feature-flags + namespace: tekton-pipelines +data: + enable-param-enum: "invalid"