@@ -22,18 +22,20 @@ This package addresses the code duplication that existed in CRD, RBAC, and Webho
2222by providing a unified API for:
2323
2424- Parsing feature gate configurations from CLI parameters
25- - Validating feature gate expressions with strict or legacy modes
25+ - Validating feature gate expressions with strict validation
2626- Evaluating complex boolean expressions (AND, OR logic)
2727- Managing known feature gates with a registry
2828
2929# Basic Usage
3030
31- The simplest way to use this package is with the legacy functions that maintain
32- backward compatibility:
31+ The simplest way to use this package is:
3332
34- gates := featuregate.ParseFeatureGatesLegacy("alpha=true,beta=false")
33+ gates, err := featuregate.ParseFeatureGates("alpha=true,beta=false", false)
34+ if err != nil {
35+ // handle error
36+ }
3537 evaluator := featuregate.NewFeatureGateEvaluator(gates)
36-
38+
3739 if evaluator.EvaluateExpression("alpha|beta") {
3840 // Include the feature
3941 }
@@ -62,19 +64,19 @@ For new implementations requiring strict validation:
6264 if err != nil {
6365 // Handle parsing error
6466 }
65-
67+
6668 err = registry.ValidateExpression("alpha|unknown")
6769 if err != nil {
6870 // Handle unknown gate error
6971 }
7072
71- # Migration from Existing Code
73+ # Integration
7274
73- This package provides legacy functions that match the behavior of existing
74- implementations in CRD, RBAC, and Webhook generators:
75+ This package provides functions that centralize the feature gate logic
76+ previously duplicated across CRD, RBAC, and Webhook generators:
7577
76- - ParseFeatureGatesLegacy () replaces individual parseFeatureGates() functions
77- - ValidateFeatureGateExpressionLegacy () replaces individual validateFeatureGateExpression() functions
78+ - ParseFeatureGates () replaces individual parseFeatureGates() functions
79+ - ValidateFeatureGateExpression () replaces individual validateFeatureGateExpression() functions
7880- FeatureGateEvaluator.EvaluateExpression() replaces individual shouldInclude*() functions
7981
8082The FeatureGateMap type is compatible with existing map[string]bool usage patterns.
0 commit comments