Skip to content

Commit 46777a8

Browse files
Updates vsphere cmd to use library-go helper
This change updates the --feature-gates flag for Vsphere controller to use the new helperfunc AddFlagsToGoFlagSet in library-go
1 parent 5629165 commit 46777a8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cmd/vsphere/main.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/openshift/machine-api-operator/pkg/version"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
"k8s.io/apiserver/pkg/util/feature"
24-
k8sflag "k8s.io/component-base/cli/flag"
2524
"k8s.io/component-base/featuregate"
2625
"k8s.io/klog/v2"
2726
"k8s.io/klog/v2/textlogger"
@@ -95,14 +94,13 @@ func main() {
9594

9695
// Sets up feature gates
9796
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)
9998
if err != nil {
10099
klog.Fatalf("Error setting up feature gates: %v", err)
101100
}
102101

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

107105
flag.Parse()
108106

@@ -148,10 +146,14 @@ func main() {
148146

149147
// Sets feature gates from flags
150148
klog.Infof("Initializing feature gates: %s", strings.Join(defaultMutableGate.KnownFeatures(), ", "))
151-
err = defaultMutableGate.SetFromMap(featureGateArgs)
149+
warnings, err := gateOpts.ApplyTo(defaultMutableGate)
152150
if err != nil {
153151
klog.Fatalf("Error setting feature gates from flags: %v", err)
154152
}
153+
if len(warnings) > 0 {
154+
klog.Infof("Warnings setting feature gates from flags: %v", warnings)
155+
}
156+
155157
klog.Infof("FeatureGateMachineAPIMigration initialised: %t", defaultMutableGate.Enabled(featuregate.Feature(apifeatures.FeatureGateMachineAPIMigration)))
156158

157159
staticIPFeatureGateEnabled := defaultMutableGate.Enabled(featuregate.Feature(apifeatures.FeatureGateVSphereStaticIPs))

0 commit comments

Comments
 (0)