@@ -21,7 +21,6 @@ import (
21
21
"github.com/openshift/machine-api-operator/pkg/version"
22
22
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23
23
"k8s.io/apiserver/pkg/util/feature"
24
- k8sflag "k8s.io/component-base/cli/flag"
25
24
"k8s.io/component-base/featuregate"
26
25
"k8s.io/klog/v2"
27
26
"k8s.io/klog/v2/textlogger"
@@ -95,14 +94,13 @@ func main() {
95
94
96
95
// Sets up feature gates
97
96
defaultMutableGate := feature .DefaultMutableFeatureGate
98
- _ , err := features .NewFeatureGateOptions (defaultMutableGate , apifeatures .SelfManaged , apifeatures .FeatureGateVSphereStaticIPs , apifeatures .FeatureGateMachineAPIMigration )
97
+ gateOpts , err := features .NewFeatureGateOptions (defaultMutableGate , apifeatures .SelfManaged , apifeatures .FeatureGateVSphereStaticIPs , apifeatures .FeatureGateMachineAPIMigration )
99
98
if err != nil {
100
99
klog .Fatalf ("Error setting up feature gates: %v" , err )
101
100
}
102
101
103
- featureGateArgs := map [string ]bool {}
104
- flag .Var (k8sflag .NewMapStringBool (& featureGateArgs ), "feature-gates" , "A set of key=value pairs that describe feature gates for alpha/experimental features. " +
105
- "Options are:\n " + strings .Join (defaultMutableGate .KnownFeatures (), "\n " ))
102
+ // Add the --feature-gates flag
103
+ gateOpts .AddFlagsToGoFlagSet (nil )
106
104
107
105
flag .Parse ()
108
106
@@ -148,10 +146,14 @@ func main() {
148
146
149
147
// Sets feature gates from flags
150
148
klog .Infof ("Initializing feature gates: %s" , strings .Join (defaultMutableGate .KnownFeatures (), ", " ))
151
- err = defaultMutableGate . SetFromMap ( featureGateArgs )
149
+ warnings , err := gateOpts . ApplyTo ( defaultMutableGate )
152
150
if err != nil {
153
151
klog .Fatalf ("Error setting feature gates from flags: %v" , err )
154
152
}
153
+ if len (warnings ) > 0 {
154
+ klog .Infof ("Warnings setting feature gates from flags: %v" , warnings )
155
+ }
156
+
155
157
klog .Infof ("FeatureGateMachineAPIMigration initialised: %t" , defaultMutableGate .Enabled (featuregate .Feature (apifeatures .FeatureGateMachineAPIMigration )))
156
158
157
159
staticIPFeatureGateEnabled := defaultMutableGate .Enabled (featuregate .Feature (apifeatures .FeatureGateVSphereStaticIPs ))
0 commit comments