Skip to content

Commit 5629165

Browse files
Updates MachineSet cmd to use library-go helper
This change updates the --feature-gates flag for MachineSets to use the new helperfunc AddFlagsToGoFlagSet in library-go
1 parent d0e62ca commit 5629165

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmd/machineset/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
machinev1 "github.com/openshift/api/machine/v1beta1"
2929
mapiwebhooks "github.com/openshift/machine-api-operator/pkg/webhooks"
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31-
k8sflag "k8s.io/component-base/cli/flag"
3231
ctrl "sigs.k8s.io/controller-runtime"
3332

3433
"github.com/openshift/library-go/pkg/config/leaderelection"
@@ -111,14 +110,13 @@ func main() {
111110

112111
// Sets up feature gates
113112
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)
115114
if err != nil {
116115
klog.Fatalf("Error setting up feature gates: %v", err)
117116
}
118117

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)
122120

123121
flag.Parse()
124122
if *watchNamespace != "" {
@@ -172,10 +170,14 @@ func main() {
172170

173171
// Sets feature gates from flags
174172
klog.Infof("Initializing feature gates: %s", strings.Join(defaultMutableGate.KnownFeatures(), ", "))
175-
err = defaultMutableGate.SetFromMap(featureGateArgs)
173+
warnings, err := gateOpts.ApplyTo(defaultMutableGate)
176174
if err != nil {
177175
klog.Fatalf("Error setting feature gates from flags: %v", err)
178176
}
177+
if len(warnings) > 0 {
178+
klog.Infof("Warnings setting feature gates from flags: %v", warnings)
179+
}
180+
179181
klog.Infof("FeatureGateMachineAPIMigration initialised: %t", defaultMutableGate.Enabled(featuregate.Feature(apifeatures.FeatureGateMachineAPIMigration)))
180182

181183
// Enable defaulting and validating webhooks

0 commit comments

Comments
 (0)