@@ -50,7 +50,7 @@ func TestHandleReconcileFailed(t *testing.T) {
50
50
defer stop ()
51
51
c := mgr .GetClient ()
52
52
mockEventRecorder := testmocks .NewMockEventRecorder (t , mgr .GetScheme ())
53
- r := ConfigConnectorReconciler {
53
+ r := Reconciler {
54
54
client : c ,
55
55
recorder : mockEventRecorder ,
56
56
}
@@ -108,7 +108,7 @@ func TestHandleReconcileSucceeded(t *testing.T) {
108
108
defer stop ()
109
109
c := mgr .GetClient ()
110
110
mockEventRecorder := testmocks .NewMockEventRecorder (t , mgr .GetScheme ())
111
- r := ConfigConnectorReconciler {
111
+ r := Reconciler {
112
112
client : c ,
113
113
recorder : mockEventRecorder ,
114
114
}
@@ -266,7 +266,7 @@ func TestHandleConfigConnectorCreate(t *testing.T) {
266
266
c := mgr .GetClient ()
267
267
testcontroller .EnsureNamespaceExists (c , k8s .CNRMSystemNamespace )
268
268
testcontroller .EnsureNamespaceExists (c , k8s .OperatorSystemNamespace )
269
- m := testcontroller .ParseObjects (t , ctx , tc .loadedManifest )
269
+ m := testcontroller .ParseObjects (ctx , t , tc .loadedManifest )
270
270
r := newConfigConnectorReconciler (c )
271
271
272
272
if err := c .Create (ctx , tc .cc ); err != nil {
@@ -284,17 +284,17 @@ func TestHandleConfigConnectorCreate(t *testing.T) {
284
284
t .Fatalf ("unexpected error: %v" , err )
285
285
}
286
286
expectedObjs := tc .resultsFunc (t , c )
287
- expectedManifest := testcontroller .ParseObjects (t , ctx , expectedObjs )
288
- expectedJson , err := expectedManifest .JSONManifest ()
287
+ expectedManifest := testcontroller .ParseObjects (ctx , t , expectedObjs )
288
+ expectedJSON , err := expectedManifest .JSONManifest ()
289
289
if err != nil {
290
290
t .Fatalf ("unexpected error: %v" , err )
291
291
}
292
- resJson , err := m .JSONManifest ()
292
+ resJSON , err := m .JSONManifest ()
293
293
if err != nil {
294
294
t .Fatalf ("unexpected error: %v" , err )
295
295
}
296
- if ! reflect .DeepEqual (resJson , expectedJson ) {
297
- t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJson , expectedJson ))
296
+ if ! reflect .DeepEqual (resJSON , expectedJSON ) {
297
+ t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJSON , expectedJSON ))
298
298
}
299
299
300
300
// Verify that CCC objects are NOT attached finalizers by the CC controller.
@@ -418,7 +418,7 @@ func TestHandleConfigConnectorDelete(t *testing.T) {
418
418
c := mgr .GetClient ()
419
419
testcontroller .EnsureNamespaceExists (c , k8s .OperatorSystemNamespace )
420
420
testcontroller .EnsureNamespaceExists (c , k8s .CNRMSystemNamespace )
421
- m := testcontroller .ParseObjects (t , ctx , tc .installedObjectsFunc (t , c ))
421
+ m := testcontroller .ParseObjects (ctx , t , tc .installedObjectsFunc (t , c ))
422
422
r := newConfigConnectorReconciler (c )
423
423
if err := c .Create (ctx , tc .cc ); err != nil {
424
424
t .Fatalf ("error creating %v %v: %v" , tc .cc .Kind , tc .cc .Name , err )
@@ -467,17 +467,17 @@ func TestHandleConfigConnectorDelete(t *testing.T) {
467
467
t .Fatalf ("unexpected error: %v" , err )
468
468
}
469
469
expectedObjs := tc .resultsFunc (t , c )
470
- expectedManifest := testcontroller .ParseObjects (t , ctx , expectedObjs )
471
- expectedJson , err := expectedManifest .JSONManifest ()
470
+ expectedManifest := testcontroller .ParseObjects (ctx , t , expectedObjs )
471
+ expectedJSON , err := expectedManifest .JSONManifest ()
472
472
if err != nil {
473
473
t .Fatalf ("unexpected error: %v" , err )
474
474
}
475
- resJson , err := m .JSONManifest ()
475
+ resJSON , err := m .JSONManifest ()
476
476
if err != nil {
477
477
t .Fatalf ("unexpected error: %v" , err )
478
478
}
479
- if ! reflect .DeepEqual (resJson , expectedJson ) {
480
- t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJson , expectedJson ))
479
+ if ! reflect .DeepEqual (resJSON , expectedJSON ) {
480
+ t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJSON , expectedJSON ))
481
481
}
482
482
483
483
// Assert that the ConfigConnector object is deleted.
@@ -761,7 +761,7 @@ func TestConfigConnectorUpdate(t *testing.T) {
761
761
}
762
762
}
763
763
installedComponents := tc .installedObjectsFunc (t , c )
764
- installedManifest := testcontroller .ParseObjects (t , ctx , installedComponents )
764
+ installedManifest := testcontroller .ParseObjects (ctx , t , installedComponents )
765
765
for _ , item := range installedManifest .Items {
766
766
if err := c .Create (ctx , item .UnstructuredObject ()); err != nil && ! apierrors .IsAlreadyExists (err ) {
767
767
t .Fatalf ("error creating %v %v: %v" , item .GroupKind (), item .GetName (), err )
@@ -774,7 +774,7 @@ func TestConfigConnectorUpdate(t *testing.T) {
774
774
t .Fatalf ("error updating %v %v: %v" , tc .updatedCc .Kind , tc .updatedCc .Name , err )
775
775
}
776
776
777
- m := testcontroller .ParseObjects (t , ctx , tc .manifest )
777
+ m := testcontroller .ParseObjects (ctx , t , tc .manifest )
778
778
if tc .cc .GetMode () == "namespaced" {
779
779
if err := handleLifecycles (t , ctx , r , tc .updatedCc , m ); err == nil {
780
780
t .Fatalf ("got nil, but want to have an error because the controller manager pod per namespace is not deleted" )
@@ -792,17 +792,17 @@ func TestConfigConnectorUpdate(t *testing.T) {
792
792
t .Fatalf ("unexpected error: %v" , err )
793
793
}
794
794
expectedObjs := tc .resultsFunc (t , c )
795
- expectedManifest := testcontroller .ParseObjects (t , ctx , expectedObjs )
796
- expectedJson , err := expectedManifest .JSONManifest ()
795
+ expectedManifest := testcontroller .ParseObjects (ctx , t , expectedObjs )
796
+ expectedJSON , err := expectedManifest .JSONManifest ()
797
797
if err != nil {
798
798
t .Fatalf ("unexpected error: %v" , err )
799
799
}
800
- resJson , err := m .JSONManifest ()
800
+ resJSON , err := m .JSONManifest ()
801
801
if err != nil {
802
802
t .Fatalf ("unexpected error: %v" , err )
803
803
}
804
- if ! reflect .DeepEqual (resJson , expectedJson ) {
805
- t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJson , expectedJson ))
804
+ if ! reflect .DeepEqual (resJSON , expectedJSON ) {
805
+ t .Fatalf ("unexpected diff: %v" , cmp .Diff (resJSON , expectedJSON ))
806
806
}
807
807
// assert unneeded components are deleted
808
808
unneededComponents := tc .toDeleteObjectsFunc (t , c )
@@ -826,22 +826,20 @@ type testCaseStruct struct {
826
826
}
827
827
828
828
func handleLifecycles (t * testing.T , ctx context.Context ,
829
- r * ConfigConnectorReconciler , cc * corev1beta1.ConfigConnector , m * manifest.Objects ) error {
829
+ r * Reconciler , cc * corev1beta1.ConfigConnector , m * manifest.Objects ) error {
830
830
t .Helper ()
831
831
832
832
fn := r .transformForClusterMode ()
833
833
if err := fn (ctx , cc , m ); err != nil {
834
834
return err
835
835
}
836
836
fn = r .handleConfigConnectorLifecycle ()
837
- if err := fn (ctx , cc , m ); err != nil {
838
- return err
839
- }
840
- return nil
837
+
838
+ return fn (ctx , cc , m )
841
839
}
842
840
843
- func newConfigConnectorReconciler (c client.Client ) * ConfigConnectorReconciler {
844
- return & ConfigConnectorReconciler {
841
+ func newConfigConnectorReconciler (c client.Client ) * Reconciler {
842
+ return & Reconciler {
845
843
client : c ,
846
844
log : logr .Discard (),
847
845
}
@@ -888,7 +886,7 @@ func TestSelectingCRDsByVersion(t *testing.T) {
888
886
mgr , stop := testmain .StartTestManagerFromNewTestEnv ()
889
887
defer stop ()
890
888
c := mgr .GetClient ()
891
- manifests := testcontroller .ParseObjects (t , ctx , tc .manifests )
889
+ manifests := testcontroller .ParseObjects (ctx , t , tc .manifests )
892
890
r := newConfigConnectorReconciler (c )
893
891
894
892
err := r .selectCRDsByVersion (manifests , tc .version )
@@ -905,7 +903,7 @@ func TestSelectingCRDsByVersion(t *testing.T) {
905
903
if err != nil {
906
904
t .Fatalf ("unexpected error: %v" , err )
907
905
}
908
- expectedManifests := testcontroller .ParseObjects (t , ctx , tc .expectedManifests )
906
+ expectedManifests := testcontroller .ParseObjects (ctx , t , tc .expectedManifests )
909
907
expectedJSON , err := expectedManifests .JSONManifest ()
910
908
if err != nil {
911
909
t .Fatalf ("unexpected error: %v" , err )
@@ -1197,7 +1195,7 @@ func TestApplyCustomizations(t *testing.T) {
1197
1195
t .Fatalf ("error creating %v %v/%v: %v" , cr .Kind , cr .Namespace , cr .Name , err )
1198
1196
}
1199
1197
}
1200
- manifests := testcontroller .ParseObjects (t , ctx , tc .manifests )
1198
+ manifests := testcontroller .ParseObjects (ctx , t , tc .manifests )
1201
1199
r := newConfigConnectorReconciler (c )
1202
1200
1203
1201
// run the test function
@@ -1207,20 +1205,20 @@ func TestApplyCustomizations(t *testing.T) {
1207
1205
}
1208
1206
1209
1207
// check the resulting manifests
1210
- gotJson , err := manifests .JSONManifest ()
1208
+ gotJSON , err := manifests .JSONManifest ()
1211
1209
if err != nil {
1212
1210
t .Fatalf ("unexpected error: %v" , err )
1213
1211
}
1214
- expectedManifests := testcontroller .ParseObjects (t , ctx , tc .expectedManifests )
1212
+ expectedManifests := testcontroller .ParseObjects (ctx , t , tc .expectedManifests )
1215
1213
if err != nil {
1216
1214
t .Fatalf ("unexpected error: %v" , err )
1217
1215
}
1218
- expectedJson , err := expectedManifests .JSONManifest ()
1216
+ expectedJSON , err := expectedManifests .JSONManifest ()
1219
1217
if err != nil {
1220
1218
t .Fatalf ("unexpected error: %v" , err )
1221
1219
}
1222
- if ! reflect .DeepEqual (gotJson , expectedJson ) {
1223
- t .Fatalf ("unexpected diff: %v" , cmp .Diff (gotJson , expectedJson ))
1220
+ if ! reflect .DeepEqual (gotJSON , expectedJSON ) {
1221
+ t .Fatalf ("unexpected diff: %v" , cmp .Diff (gotJSON , expectedJSON ))
1224
1222
}
1225
1223
1226
1224
// check the status of cluster-scoped customization CR
@@ -1239,8 +1237,8 @@ func TestApplyCustomizations(t *testing.T) {
1239
1237
}
1240
1238
}
1241
1239
1242
- func newConfigConnectorReconcilerWithCustomizationWatcher (m ctrl.Manager ) * ConfigConnectorReconciler {
1243
- r := & ConfigConnectorReconciler {
1240
+ func newConfigConnectorReconcilerWithCustomizationWatcher (m ctrl.Manager ) * Reconciler {
1241
+ r := & Reconciler {
1244
1242
client : m .GetClient (),
1245
1243
log : logr .Discard (),
1246
1244
}
0 commit comments