@@ -28,7 +28,6 @@ import (
28
28
machinev1 "github.com/openshift/api/machine/v1beta1"
29
29
mapiwebhooks "github.com/openshift/machine-api-operator/pkg/webhooks"
30
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31
- k8sflag "k8s.io/component-base/cli/flag"
32
31
ctrl "sigs.k8s.io/controller-runtime"
33
32
34
33
"github.com/openshift/library-go/pkg/config/leaderelection"
@@ -111,14 +110,13 @@ func main() {
111
110
112
111
// Sets up feature gates
113
112
defaultMutableGate := feature .DefaultMutableFeatureGate
114
- _ , err := features .NewFeatureGateOptions (defaultMutableGate , apifeatures .SelfManaged , apifeatures .FeatureGateVSphereStaticIPs , apifeatures .FeatureGateMachineAPIMigration )
113
+ gateOpts , err := features .NewFeatureGateOptions (defaultMutableGate , apifeatures .SelfManaged , apifeatures .FeatureGateVSphereStaticIPs , apifeatures .FeatureGateMachineAPIMigration )
115
114
if err != nil {
116
115
klog .Fatalf ("Error setting up feature gates: %v" , err )
117
116
}
118
117
119
- featureGateArgs := map [string ]bool {}
120
- flag .Var (k8sflag .NewMapStringBool (& featureGateArgs ), "feature-gates" , "A set of key=value pairs that describe feature gates for alpha/experimental features. " +
121
- "Options are:\n " + strings .Join (defaultMutableGate .KnownFeatures (), "\n " ))
118
+ // Add the --feature-gates flag
119
+ gateOpts .AddFlagsToGoFlagSet (nil )
122
120
123
121
flag .Parse ()
124
122
if * watchNamespace != "" {
@@ -172,10 +170,14 @@ func main() {
172
170
173
171
// Sets feature gates from flags
174
172
klog .Infof ("Initializing feature gates: %s" , strings .Join (defaultMutableGate .KnownFeatures (), ", " ))
175
- err = defaultMutableGate . SetFromMap ( featureGateArgs )
173
+ warnings , err := gateOpts . ApplyTo ( defaultMutableGate )
176
174
if err != nil {
177
175
klog .Fatalf ("Error setting feature gates from flags: %v" , err )
178
176
}
177
+ if len (warnings ) > 0 {
178
+ klog .Infof ("Warnings setting feature gates from flags: %v" , warnings )
179
+ }
180
+
179
181
klog .Infof ("FeatureGateMachineAPIMigration initialised: %t" , defaultMutableGate .Enabled (featuregate .Feature (apifeatures .FeatureGateMachineAPIMigration )))
180
182
181
183
// Enable defaulting and validating webhooks
0 commit comments