Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEP-0147: introduce feature flag to guard artifacts feature #7705

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/config-feature-flags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 15 additions & 1 deletion pkg/apis/config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ 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"

// EnableParamEnum is the flag to enabled enum in params
EnableParamEnum = "enable-param-enum"

Expand Down Expand Up @@ -145,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,
Expand Down Expand Up @@ -183,6 +192,7 @@ type FeatureFlags struct {
EnableCELInWhenExpression bool
EnableStepActions bool
EnableParamEnum bool
EnableArtifacts bool
}

// GetFeatureFlagsConfigName returns the name of the configmap containing all
Expand Down Expand Up @@ -277,6 +287,10 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) {
if err := setPerFeatureFlag(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil {
return nil, err
}

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
// enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of
// each feature's individual flag.
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/config/testdata/feature-flags-all-flags-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ data:
enable-cel-in-whenexpression: "true"
enable-step-actions: "true"
enable-param-enum: "true"
enable-artifacts: "true"
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions test/e2e-tests-kind-prow-alpha.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ RESULTS_FROM=sidecar-logs
ENABLE_STEP_ACTIONS=true
ENABLE_CEL_IN_WHENEXPRESSION=true
ENABLE_PARAM_ENUM=true
ENABLE_ARTIFACTS=true
14 changes: 14 additions & 0 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/featureflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
JeromeJu marked this conversation as resolved.
Show resolved Hide resolved
})
if err != nil {
t.Fatalf("error creating alpha feature flags configmap: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion test/per_feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down