From feb12a8b3fa63fb4ebbdc55ed90d459684f2b241 Mon Sep 17 00:00:00 2001 From: zhujian Date: Tue, 29 Oct 2024 03:37:53 +0000 Subject: [PATCH] Explicitly disable the feature gate that is enabled by default Signed-off-by: zhujian --- pkg/genericclioptions/feature_gates.go | 4 +++- pkg/genericclioptions/feature_gates_test.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/genericclioptions/feature_gates.go b/pkg/genericclioptions/feature_gates.go index 2c516c8a..26e51dec 100644 --- a/pkg/genericclioptions/feature_gates.go +++ b/pkg/genericclioptions/feature_gates.go @@ -20,7 +20,6 @@ func init() { // Update default features utilruntime.Must(HubMutableFeatureGate.SetFromMap(map[string]bool{string(ocmfeature.DefaultClusterSet): true})) - utilruntime.Must(SpokeMutableFeatureGate.SetFromMap(map[string]bool{string(ocmfeature.AddonManagement): true})) } func ConvertToFeatureGateAPI(featureGates featuregate.MutableFeatureGate, defaultFeatureGate map[featuregate.Feature]featuregate.FeatureSpec) []operatorv1.FeatureGate { @@ -34,6 +33,9 @@ func ConvertToFeatureGateAPI(featureGates featuregate.MutableFeatureGate, defaul } if featureGates.Enabled(feature) { features = append(features, operatorv1.FeatureGate{Feature: string(feature), Mode: operatorv1.FeatureGateModeTypeEnable}) + } else if defaultFeatureGate[feature].Default { + // Explicitly disable the feature gate that is enabled by default + features = append(features, operatorv1.FeatureGate{Feature: string(feature), Mode: operatorv1.FeatureGateModeTypeDisable}) } } diff --git a/pkg/genericclioptions/feature_gates_test.go b/pkg/genericclioptions/feature_gates_test.go index e3bafdb2..662096f2 100644 --- a/pkg/genericclioptions/feature_gates_test.go +++ b/pkg/genericclioptions/feature_gates_test.go @@ -27,7 +27,9 @@ func TestConvertToFeatureGateAPI(t *testing.T) { return fg }, defaultFeatureGate: ocmfeature.DefaultHubAddonManagerFeatureGates, - expected: []operatorv1.FeatureGate{}, + expected: []operatorv1.FeatureGate{ + {Feature: "AddonManagement", Mode: operatorv1.FeatureGateModeTypeDisable}, + }, }, { name: "enable default feature gate",