@@ -11,8 +11,8 @@ import (
1111 . "github.com/onsi/gomega"
1212 configv1 "github.com/openshift/api/config/v1"
1313 operatorv1 "github.com/openshift/api/operator/v1"
14- "github.com/openshift/library-go/pkg/cloudprovider"
1514 "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
15+ "github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
1616 appsv1 "k8s.io/api/apps/v1"
1717 corev1 "k8s.io/api/core/v1"
1818 "k8s.io/apimachinery/pkg/api/equality"
@@ -221,21 +221,16 @@ func constructKeyForWatchedObject(object client.Object, scheme *runtime.Scheme)
221221
222222var _ = Describe ("Component sync controller" , func () {
223223 var infra * configv1.Infrastructure
224- var fg * configv1.FeatureGate
225224 var kcm * operatorv1.KubeControllerManager
226225 var co * configv1.ClusterOperator
227226 var operatorController * CloudOperatorReconciler
228227 var operands []client.Object
229228 var watcher mockedWatcher
230229
231- externalFeatureGateSpec := & configv1.FeatureGateSpec {
232- FeatureGateSelection : configv1.FeatureGateSelection {
233- FeatureSet : configv1 .CustomNoUpgrade ,
234- CustomNoUpgrade : & configv1.CustomFeatureGates {
235- Enabled : []configv1.FeatureGateName {cloudprovider .ExternalCloudProviderFeature },
236- },
237- },
238- }
230+ externalFeatureGateAccessor := featuregates .NewHardcodedFeatureGateAccess (
231+ []configv1.FeatureGateName {configv1 .FeatureGateExternalCloudProvider },
232+ nil ,
233+ )
239234
240235 kcmStatus := & operatorv1.KubeControllerManagerStatus {
241236 StaticPodOperatorStatus : operatorv1.StaticPodOperatorStatus {
@@ -299,9 +294,6 @@ var _ = Describe("Component sync controller", func() {
299294 infra = & configv1.Infrastructure {}
300295 infra .SetName (infrastructureResourceName )
301296
302- fg = & configv1.FeatureGate {}
303- fg .SetName (externalFeatureGateName )
304-
305297 kcm = & operatorv1.KubeControllerManager {
306298 ObjectMeta : metav1.ObjectMeta {
307299 Name : kcmResourceName ,
@@ -326,29 +318,27 @@ var _ = Describe("Component sync controller", func() {
326318 ManagedNamespace : testManagedNamespace ,
327319 Recorder : record .NewFakeRecorder (32 ),
328320 },
329- Scheme : scheme .Scheme ,
330- watcher : w ,
331- ImagesFile : testImagesFilePath ,
321+ Scheme : scheme .Scheme ,
322+ watcher : w ,
323+ ImagesFile : testImagesFilePath ,
324+ FeatureGateAccess : featuregates .NewHardcodedFeatureGateAccess (nil , nil ),
332325 }
333326 originalWatcher , _ := w .(* objectWatcher )
334327 watcher = mockedWatcher {watcher : originalWatcher }
335328
336329 Expect (cl .Create (context .Background (), infra .DeepCopy ())).To (Succeed ())
337- Expect (cl .Create (context .Background (), fg .DeepCopy ())).To (Succeed ())
338330 Expect (cl .Create (context .Background (), kcm .DeepCopy ())).To (Succeed ())
339331 Expect (cl .Create (context .Background (), co .DeepCopy ())).To (Succeed ())
340332 })
341333
342334 AfterEach (func () {
343335 Expect (cl .Delete (context .Background (), infra .DeepCopy ())).To (Succeed ())
344- Expect (cl .Delete (context .Background (), fg .DeepCopy ())).To (Succeed ())
345336 Expect (cl .Delete (context .Background (), kcm .DeepCopy ())).To (Succeed ())
346337 Expect (cl .Delete (context .Background (), co .DeepCopy ())).To (Succeed ())
347338
348339 Eventually (func () bool {
349340 return apierrors .IsNotFound (cl .Get (context .Background (), client .ObjectKeyFromObject (infra ), infra .DeepCopy ())) &&
350- apierrors .IsNotFound (cl .Get (context .Background (), client .ObjectKeyFromObject (fg ), fg .DeepCopy ())) &&
351- apierrors .IsNotFound (cl .Get (context .Background (), client .ObjectKeyFromObject (co ), fg .DeepCopy ())) &&
341+ apierrors .IsNotFound (cl .Get (context .Background (), client .ObjectKeyFromObject (co ), co .DeepCopy ())) &&
352342 apierrors .IsNotFound (cl .Get (context .Background (), client .ObjectKeyFromObject (kcm ), kcm .DeepCopy ()))
353343 }, timeout ).Should (BeTrue ())
354344
@@ -363,7 +353,7 @@ var _ = Describe("Component sync controller", func() {
363353
364354 type testCase struct {
365355 status * configv1.InfrastructureStatus
366- featureGateSpec * configv1. FeatureGateSpec
356+ featureGate featuregates. FeatureGateAccess
367357 kcmStatus * operatorv1.KubeControllerManagerStatus
368358 coStatus * configv1.ClusterOperatorStatus
369359 expectProvisioned bool
@@ -376,10 +366,8 @@ var _ = Describe("Component sync controller", func() {
376366 infra .Status = * tc .status
377367 Expect (cl .Status ().Update (context .Background (), infra .DeepCopy ())).To (Succeed ())
378368
379- if tc .featureGateSpec != nil {
380- Expect (cl .Get (context .Background (), client .ObjectKeyFromObject (fg ), fg )).To (Succeed ())
381- fg .Spec = * tc .featureGateSpec
382- Expect (cl .Update (context .Background (), fg .DeepCopy ())).To (Succeed ())
369+ if tc .featureGate != nil {
370+ operatorController .FeatureGateAccess = tc .featureGate
383371 }
384372
385373 if tc .kcmStatus != nil {
@@ -454,7 +442,7 @@ var _ = Describe("Component sync controller", func() {
454442 Type : configv1 .AWSPlatformType ,
455443 },
456444 },
457- featureGateSpec : externalFeatureGateSpec ,
445+ featureGate : externalFeatureGateAccessor ,
458446 kcmStatus : kcmStatus ,
459447 coStatus : coStatus ,
460448 expectProvisioned : true ,
@@ -468,7 +456,7 @@ var _ = Describe("Component sync controller", func() {
468456 Type : configv1 .OpenStackPlatformType ,
469457 },
470458 },
471- featureGateSpec : externalFeatureGateSpec ,
459+ featureGate : externalFeatureGateAccessor ,
472460 kcmStatus : kcmStatus ,
473461 coStatus : coStatus ,
474462 expectProvisioned : true ,
@@ -482,7 +470,7 @@ var _ = Describe("Component sync controller", func() {
482470 Type : configv1 .AWSPlatformType ,
483471 },
484472 },
485- featureGateSpec : externalFeatureGateSpec ,
473+ featureGate : externalFeatureGateAccessor ,
486474 kcmStatus : & operatorv1.KubeControllerManagerStatus {},
487475 coStatus : coStatus ,
488476 expectProvisioned : true ,
@@ -496,7 +484,7 @@ var _ = Describe("Component sync controller", func() {
496484 Type : configv1 .KubevirtPlatformType ,
497485 },
498486 },
499- featureGateSpec : externalFeatureGateSpec ,
487+ featureGate : externalFeatureGateAccessor ,
500488 kcmStatus : kcmStatus ,
501489 coStatus : coStatus ,
502490 expectProvisioned : false ,
@@ -534,7 +522,7 @@ var _ = Describe("Component sync controller", func() {
534522 Type : configv1 .AWSPlatformType ,
535523 },
536524 },
537- featureGateSpec : externalFeatureGateSpec ,
525+ featureGate : externalFeatureGateAccessor ,
538526 kcmStatus : & operatorv1.KubeControllerManagerStatus {
539527 StaticPodOperatorStatus : operatorv1.StaticPodOperatorStatus {
540528 OperatorStatus : operatorv1.OperatorStatus {
@@ -560,7 +548,7 @@ var _ = Describe("Component sync controller", func() {
560548 Type : configv1 .AWSPlatformType ,
561549 },
562550 },
563- featureGateSpec : externalFeatureGateSpec ,
551+ featureGate : externalFeatureGateAccessor ,
564552 kcmStatus : & operatorv1.KubeControllerManagerStatus {
565553 StaticPodOperatorStatus : operatorv1.StaticPodOperatorStatus {
566554 OperatorStatus : operatorv1.OperatorStatus {
@@ -586,8 +574,8 @@ var _ = Describe("Component sync controller", func() {
586574 Type : configv1 .AWSPlatformType ,
587575 },
588576 },
589- featureGateSpec : externalFeatureGateSpec ,
590- kcmStatus : kcmStatus ,
577+ featureGate : externalFeatureGateAccessor ,
578+ kcmStatus : kcmStatus ,
591579 coStatus : & configv1.ClusterOperatorStatus {
592580 Conditions : []configv1.ClusterOperatorStatusCondition {
593581 {
@@ -624,8 +612,8 @@ var _ = Describe("Component sync controller", func() {
624612 Type : configv1 .AWSPlatformType ,
625613 },
626614 },
627- featureGateSpec : externalFeatureGateSpec ,
628- kcmStatus : kcmStatus ,
615+ featureGate : externalFeatureGateAccessor ,
616+ kcmStatus : kcmStatus ,
629617 coStatus : & configv1.ClusterOperatorStatus {
630618 Conditions : []configv1.ClusterOperatorStatusCondition {
631619 {
0 commit comments