Skip to content

Commit

Permalink
Explicitly disable the feature gate that is enabled by default (#456)
Browse files Browse the repository at this point in the history
Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 authored Oct 29, 2024
1 parent e5a4b77 commit fae815d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/genericclioptions/feature_gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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})
}
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/genericclioptions/feature_gates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fae815d

Please sign in to comment.