From 295db6bf5b119a99002286f200265222bb2c68ae Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:37:43 -0500 Subject: [PATCH 1/3] kind/misc: introduce feature flag to guard artifacts feature --- config/config-feature-flags.yaml | 3 +++ pkg/apis/config/feature_flags.go | 11 +++++++++- pkg/apis/config/feature_flags_test.go | 4 ++++ .../testdata/feature-flags-all-flags-set.yaml | 1 + ...eature-flags-invalid-enable-artifacts.yaml | 21 +++++++++++++++++++ test/e2e-tests-kind-prow-alpha.env | 1 + test/e2e-tests.sh | 14 +++++++++++++ test/featureflags.go | 1 + 8 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 pkg/apis/config/testdata/feature-flags-invalid-enable-artifacts.yaml diff --git a/config/config-feature-flags.yaml b/config/config-feature-flags.yaml index 83c8ee98e01..6cb5073da37 100644 --- a/config/config-feature-flags.yaml +++ b/config/config-feature-flags.yaml @@ -126,5 +126,8 @@ data: # 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 use of Artifacts in Steps + # This feature is in preview mode and not implemented yet. Please check #7693 for updates. + enable-artifacts: "false" # Setting this flag to "true" will enable the built-in param input validation via param enum. enable-param-enum: "false" diff --git a/pkg/apis/config/feature_flags.go b/pkg/apis/config/feature_flags.go index 86757f0d55b..23c138bcbe8 100644 --- a/pkg/apis/config/feature_flags.go +++ b/pkg/apis/config/feature_flags.go @@ -100,7 +100,11 @@ const ( EnableCELInWhenExpression = "enable-cel-in-whenexpression" // EnableStepActions is the flag to enable the use of StepActions in Steps EnableStepActions = "enable-step-actions" - // DefaultEnableStepActions is the default value for EnableStepActions + + // EnableArtifacts is the flag to enable the use of Artifacts in Steps + EnableArtifacts = "enable-artifacts" + // DefaultEnableArtifacts is the default value for EnableStepActions + DefaultEnableArtifacts = false // EnableParamEnum is the flag to enabled enum in params EnableParamEnum = "enable-param-enum" @@ -183,6 +187,7 @@ type FeatureFlags struct { EnableCELInWhenExpression bool EnableStepActions bool EnableParamEnum bool + EnableArtifacts bool } // GetFeatureFlagsConfigName returns the name of the configmap containing all @@ -277,6 +282,10 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { if err := setPerFeatureFlag(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil { return nil, err } + + if err := setFeature(EnableStepActions, DefaultEnableArtifacts, &tc.EnableArtifacts); err != nil { + return nil, err + } // Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if // enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of // each feature's individual flag. diff --git a/pkg/apis/config/feature_flags_test.go b/pkg/apis/config/feature_flags_test.go index a5386741746..5cf208ba594 100644 --- a/pkg/apis/config/feature_flags_test.go +++ b/pkg/apis/config/feature_flags_test.go @@ -79,6 +79,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { Coschedule: config.CoscheduleDisabled, EnableCELInWhenExpression: true, EnableStepActions: true, + EnableArtifacts: true, EnableParamEnum: true, }, fileName: "feature-flags-all-flags-set", @@ -303,6 +304,9 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) { }, { fileName: "feature-flags-invalid-enable-param-enum", want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax for feature enable-param-enum`, + }, { + fileName: "feature-flags-invalid-enable-artifacts", + want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax for feature enable-artifacts`, }} { 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 349527d4125..51f312c52b0 100644 --- a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml +++ b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml @@ -35,3 +35,4 @@ data: enable-cel-in-whenexpression: "true" enable-step-actions: "true" enable-param-enum: "true" + enable-artifacts: "true" diff --git a/pkg/apis/config/testdata/feature-flags-invalid-enable-artifacts.yaml b/pkg/apis/config/testdata/feature-flags-invalid-enable-artifacts.yaml new file mode 100644 index 00000000000..17f5dd6bcd7 --- /dev/null +++ b/pkg/apis/config/testdata/feature-flags-invalid-enable-artifacts.yaml @@ -0,0 +1,21 @@ +# Copyright 2024 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-artifacts: "invalid" \ No newline at end of file diff --git a/test/e2e-tests-kind-prow-alpha.env b/test/e2e-tests-kind-prow-alpha.env index 221744ca073..255bdf63579 100644 --- a/test/e2e-tests-kind-prow-alpha.env +++ b/test/e2e-tests-kind-prow-alpha.env @@ -7,3 +7,4 @@ RESULTS_FROM=sidecar-logs ENABLE_STEP_ACTIONS=true ENABLE_CEL_IN_WHENEXPRESSION=true ENABLE_PARAM_ENUM=true +ENABLE_ARTIFACTS=true diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index adddba171a7..15d75139c8d 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -31,6 +31,7 @@ RESULTS_FROM=${RESULTS_FROM:-termination-message} ENABLE_STEP_ACTIONS=${ENABLE_STEP_ACTIONS:="false"} ENABLE_CEL_IN_WHENEXPRESSION=${ENABLE_CEL_IN_WHENEXPRESSION:="false"} ENABLE_PARAM_ENUM=${ENABLE_PARAM_ENUM:="false"} +ENABLE_ARTIFACTS=${ENABLE_ARTIFACTS:="false"} failed=0 # Script entry point. @@ -116,6 +117,18 @@ function set_enable_param_enum() { kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" } +function set_enable_artifacts() { + local method="$1" + if [ "$method" != "false" ] && [ "$method" != "true" ]; then + printf "Invalid value for enable-artifacts %s\n" ${method} + exit 255 + fi + printf "Setting enable-artifacts to %s\n", ${method} + jsonpatch=$(printf "{\"data\": {\"enable-artifacts\": \"%s\"}}" $1) + echo "feature-flags ConfigMap patch: ${jsonpatch}" + kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" +} + function run_e2e() { # Run the integration tests header "Running Go e2e tests" @@ -142,6 +155,7 @@ set_result_extraction_method "$RESULTS_FROM" set_enable_step_actions "$ENABLE_STEP_ACTIONS" set_cel_in_whenexpression "$ENABLE_CEL_IN_WHENEXPRESSION" set_enable_param_enum "$ENABLE_PARAM_ENUM" +set_enable_artifacts "$ENABLE_ARTIFACTS" run_e2e (( failed )) && fail_test diff --git a/test/featureflags.go b/test/featureflags.go index 5304f1e190f..673d82cb75f 100644 --- a/test/featureflags.go +++ b/test/featureflags.go @@ -117,6 +117,7 @@ func getFeatureFlagsBaseOnAPIFlag(t *testing.T) *config.FeatureFlags { "enable-step-actions": "true", "enable-cel-in-whenexpression": "true", "enable-param-enum": "true", + "enable-artifacts": "true", }) if err != nil { t.Fatalf("error creating alpha feature flags configmap: %v", err) From 2559a5d80a60b3eb8d1a109ec2d4cd57838e047d Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:38:05 -0500 Subject: [PATCH 2/3] chore: copy paste error and test --- pkg/apis/config/feature_flags.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/apis/config/feature_flags.go b/pkg/apis/config/feature_flags.go index 23c138bcbe8..d4be3c024ee 100644 --- a/pkg/apis/config/feature_flags.go +++ b/pkg/apis/config/feature_flags.go @@ -103,8 +103,7 @@ const ( // EnableArtifacts is the flag to enable the use of Artifacts in Steps EnableArtifacts = "enable-artifacts" - // DefaultEnableArtifacts is the default value for EnableStepActions - DefaultEnableArtifacts = false + // EnableParamEnum is the flag to enabled enum in params EnableParamEnum = "enable-param-enum" @@ -149,6 +148,12 @@ var ( Stability: AlphaAPIFields, Enabled: DefaultAlphaFeatureEnabled} + // DefaultEnableArtifacts is the default PerFeatureFlag value for EnableStepActions + DefaultEnableArtifacts = PerFeatureFlag{ + Name: EnableStepActions, + Stability: AlphaAPIFields, + Enabled: DefaultAlphaFeatureEnabled} + // DefaultEnableParamEnum is the default PerFeatureFlag value for EnableParamEnum DefaultEnableParamEnum = PerFeatureFlag{ Name: EnableParamEnum, @@ -283,7 +288,7 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { return nil, err } - if err := setFeature(EnableStepActions, DefaultEnableArtifacts, &tc.EnableArtifacts); err != nil { + if err := setPerFeatureFlag(EnableArtifacts, DefaultEnableArtifacts, &tc.EnableArtifacts); err != nil { return nil, err } // Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if From 0f708de26ba5befd7189abc9f9968f80d67e1aee Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Tue, 27 Feb 2024 10:32:37 -0500 Subject: [PATCH 3/3] chore: add enable-artifacts to alphaFeatureFlags in per_feature_flags_test.go --- test/per_feature_flags_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/per_feature_flags_test.go b/test/per_feature_flags_test.go index 4da9124b950..4555d2010c9 100644 --- a/test/per_feature_flags_test.go +++ b/test/per_feature_flags_test.go @@ -47,7 +47,7 @@ const ( ) var ( - alphaFeatureFlags = []string{"enable-param-enum", "enable-step-actions", "keep-pod-enabled-cancel", "enable-cel-in-whenexpression"} + alphaFeatureFlags = []string{"enable-param-enum", "enable-step-actions", "keep-pod-enabled-cancel", "enable-cel-in-whenexpression", "enable-artifacts"} betaFeatureFlags = []string{} perFeatureFlags = map[string][]string{ "alpha": alphaFeatureFlags,