@@ -17,20 +17,24 @@ import (
17
17
"flag"
18
18
"fmt"
19
19
"os"
20
+ "strings"
20
21
"time"
21
22
22
23
configv1 "github.com/openshift/api/config/v1"
24
+ apifeatures "github.com/openshift/api/features"
23
25
machinev1 "github.com/openshift/api/machine/v1"
24
26
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
27
+ "github.com/openshift/library-go/pkg/features"
25
28
"github.com/openshift/machine-api-operator/pkg/controller/machine"
26
29
"github.com/openshift/machine-api-operator/pkg/metrics"
27
30
machineactuator "github.com/openshift/machine-api-provider-aws/pkg/actuators/machine"
28
31
machinesetcontroller "github.com/openshift/machine-api-provider-aws/pkg/actuators/machineset"
29
32
awsclient "github.com/openshift/machine-api-provider-aws/pkg/client"
30
33
"github.com/openshift/machine-api-provider-aws/pkg/version"
31
34
corev1 "k8s.io/api/core/v1"
35
+ "k8s.io/apiserver/pkg/util/feature"
32
36
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
33
- k8sflag "k8s.io/component-base/cli/flag "
37
+ "k8s.io/component-base/featuregate "
34
38
"k8s.io/klog/v2"
35
39
"k8s.io/klog/v2/klogr"
36
40
ctrl "sigs.k8s.io/controller-runtime"
@@ -93,8 +97,15 @@ func main() {
93
97
"The address for health checking." ,
94
98
)
95
99
96
- featureGateArgs := map [string ]bool {}
97
- flag .Var (k8sflag .NewMapStringBool (& featureGateArgs ), "feature-gates" , "A set of key=value pairs that describe feature gates for alpha/experimen" )
100
+ // Sets up feature gates
101
+ defaultMutableGate := feature .DefaultMutableFeatureGate
102
+ gateOpts , err := features .NewFeatureGateOptions (defaultMutableGate , apifeatures .SelfManaged , apifeatures .FeatureGateMachineAPIMigration )
103
+ if err != nil {
104
+ klog .Fatalf ("Error setting up feature gates: %v" , err )
105
+ }
106
+
107
+ // Add the --feature-gates flag
108
+ gateOpts .AddFlagsToGoFlagSet (nil )
98
109
99
110
klog .InitFlags (nil )
100
111
flag .Set ("logtostderr" , "true" )
@@ -137,6 +148,18 @@ func main() {
137
148
klog .Infof ("Watching machine-api objects only in namespace %q for reconciliation." , * watchNamespace )
138
149
}
139
150
151
+ // Sets feature gates from flags
152
+ klog .Infof ("Initializing feature gates: %s" , strings .Join (defaultMutableGate .KnownFeatures (), ", " ))
153
+ warnings , err := gateOpts .ApplyTo (defaultMutableGate )
154
+ if err != nil {
155
+ klog .Fatalf ("Error setting feature gates from flags: %v" , err )
156
+ }
157
+ if len (warnings ) > 0 {
158
+ klog .Infof ("Warnings setting feature gates from flags: %v" , warnings )
159
+ }
160
+
161
+ klog .Infof ("FeatureGateMachineAPIMigration initialised: %t" , defaultMutableGate .Enabled (featuregate .Feature (apifeatures .FeatureGateMachineAPIMigration )))
162
+
140
163
mgr , err := manager .New (cfg , opts )
141
164
if err != nil {
142
165
klog .Fatalf ("Error creating manager: %v" , err )
@@ -175,7 +198,7 @@ func main() {
175
198
RegionCache : describeRegionsCache ,
176
199
})
177
200
178
- if err := machine .AddWithActuator (mgr , machineActuator ); err != nil {
201
+ if err := machine .AddWithActuator (mgr , machineActuator , defaultMutableGate ); err != nil {
179
202
klog .Fatalf ("Error adding actuator: %v" , err )
180
203
}
181
204
0 commit comments