diff --git a/config/config-feature-flags.yaml b/config/config-feature-flags.yaml index 50eaa68519b..a49d26ccb78 100644 --- a/config/config-feature-flags.yaml +++ b/config/config-feature-flags.yaml @@ -124,3 +124,6 @@ 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" + # 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" diff --git a/pkg/apis/config/feature_flags.go b/pkg/apis/config/feature_flags.go index 6b4940c0880..656de7c8a93 100644 --- a/pkg/apis/config/feature_flags.go +++ b/pkg/apis/config/feature_flags.go @@ -96,6 +96,10 @@ const ( EnableCELInWhenExpression = "enable-cel-in-whenexpression" // DefaultEnableCELInWhenExpression is the default value for EnableCELInWhenExpression DefaultEnableCELInWhenExpression = false + // EnableStepActions is the flag to enable the use of StepActions in Steps + EnableStepActions = "enable-step-actions" + // DefaultEnableStepActions is the default value for EnableStepActions + DefaultEnableStepActions = false disableAffinityAssistantKey = "disable-affinity-assistant" disableCredsInitKey = "disable-creds-init" @@ -145,6 +149,7 @@ type FeatureFlags struct { SetSecurityContext bool Coschedule string EnableCELInWhenExpression bool + EnableStepActions bool } // GetFeatureFlagsConfigName returns the name of the configmap containing all @@ -220,6 +225,9 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { if err := setFeature(EnableCELInWhenExpression, DefaultEnableCELInWhenExpression, &tc.EnableCELInWhenExpression); err != nil { return nil, err } + if err := setFeature(EnableStepActions, DefaultEnableStepActions, &tc.EnableStepActions); 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 65756040698..afa954c8d4d 100644 --- a/pkg/apis/config/feature_flags_test.go +++ b/pkg/apis/config/feature_flags_test.go @@ -74,6 +74,7 @@ func TestNewFeatureFlagsFromConfigMap(t *testing.T) { SetSecurityContext: true, Coschedule: config.CoscheduleDisabled, EnableCELInWhenExpression: true, + EnableStepActions: true, }, fileName: "feature-flags-all-flags-set", }, @@ -273,6 +274,9 @@ func TestNewFeatureFlagsConfigMapErrors(t *testing.T) { }, { fileName: "feature-flags-invalid-enable-cel-in-whenexpression", want: `failed parsing feature flags config "invalid": strconv.ParseBool: parsing "invalid": invalid syntax`, + }, { + fileName: "feature-flags-invalid-enable-step-actions", + 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 63015ec07c1..bf087e8a427 100644 --- a/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml +++ b/pkg/apis/config/testdata/feature-flags-all-flags-set.yaml @@ -33,3 +33,4 @@ data: set-security-context: "true" keep-pod-on-cancel: "true" enable-cel-in-whenexpression: "true" + enable-step-actions: "true" diff --git a/pkg/apis/config/testdata/feature-flags-invalid-enable-step-actions.yaml b/pkg/apis/config/testdata/feature-flags-invalid-enable-step-actions.yaml new file mode 100644 index 00000000000..462a31704aa --- /dev/null +++ b/pkg/apis/config/testdata/feature-flags-invalid-enable-step-actions.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-step-actions: "invalid" diff --git a/test/custom_task_test.go b/test/custom_task_test.go index 604f66db2b5..f3b7e93b9b4 100644 --- a/test/custom_task_test.go +++ b/test/custom_task_test.go @@ -732,6 +732,7 @@ func getFeatureFlagsBaseOnAPIFlag(t *testing.T) *config.FeatureFlags { "enable-api-fields": "alpha", "results-from": "sidecar-logs", "enable-tekton-oci-bundles": "true", + "enable-step-actions": "true", }) if err != nil { t.Fatalf("error creating alpha feature flags configmap: %v", err) diff --git a/test/e2e-tests-kind-prow-alpha.env b/test/e2e-tests-kind-prow-alpha.env index 42f84533ab9..ee5f4c964bc 100644 --- a/test/e2e-tests-kind-prow-alpha.env +++ b/test/e2e-tests-kind-prow-alpha.env @@ -4,3 +4,4 @@ RUN_YAML_TESTS=true KO_DOCKER_REPO=registry.local:5000 E2E_GO_TEST_TIMEOUT=40m RESULTS_FROM=sidecar-logs +ENABLE_STEP_ACTIONS=true diff --git a/test/e2e-tests.sh b/test/e2e-tests.sh index 97f62d4d172..298741b9eca 100755 --- a/test/e2e-tests.sh +++ b/test/e2e-tests.sh @@ -27,6 +27,7 @@ RUN_YAML_TESTS=${RUN_YAML_TESTS:="true"} SKIP_GO_E2E_TESTS=${SKIP_GO_E2E_TESTS:="false"} E2E_GO_TEST_TIMEOUT=${E2E_GO_TEST_TIMEOUT:="20m"} RESULTS_FROM=${RESULTS_FROM:-termination-message} +ENABLE_STEP_ACTIONS=${ENABLE_STEP_ACTIONS:="false"} failed=0 # Script entry point. @@ -77,6 +78,18 @@ function set_result_extraction_method() { kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" } +function set_enable_step_actions() { + local method="$1" + if [ "$method" != "false" ] && [ "$method" != "true" ]; then + printf "Invalid value for enable-step-actions %s\n" ${method} + exit 255 + fi + printf "Setting enable-step-actions to %s\n", ${method} + jsonpatch=$(printf "{\"data\": {\"enable-step-actions\": \"%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" @@ -96,6 +109,7 @@ function run_e2e() { add_spire "$PIPELINE_FEATURE_GATE" set_feature_gate "$PIPELINE_FEATURE_GATE" set_result_extraction_method "$RESULTS_FROM" +set_enable_step_actions "$ENABLE_STEP_ACTIONS" run_e2e (( failed )) && fail_test