@@ -298,13 +298,14 @@ func NewFakeOperator(ctx context.Context, options ...fakeOperatorOption) (*Opera
298
298
* config .actionLog = append (* config .actionLog , action )
299
299
return false , nil , nil
300
300
}))
301
- config .operatorClient = operatorclient .NewClient (k8sClientFake , apiextensionsfake .NewSimpleClientset (config .extObjs ... ), apiregistrationfake .NewSimpleClientset (config .regObjs ... ))
301
+ apiextensionsFake := apiextensionsfake .NewSimpleClientset (config .extObjs ... )
302
+ config .operatorClient = operatorclient .NewClient (k8sClientFake , apiextensionsFake , apiregistrationfake .NewSimpleClientset (config .regObjs ... ))
302
303
config .configClient = configfake .NewSimpleClientset ()
303
304
metadataFake := metadatafake .NewSimpleMetadataClient (scheme , config .partialMetadata ... )
304
305
config .metadataClient = metadataFake
305
306
// It's a travesty that we need to do this, but the fakes leave us no other option. In the API server, of course
306
307
// changes to objects are transparently exposed in the metadata client. In fake-land, we need to enforce that ourselves.
307
- externalFake . PrependReactor ( "*" , "*" , func (action clienttesting.Action ) (bool , runtime.Object , error ) {
308
+ propagate := func (action clienttesting.Action ) (bool , runtime.Object , error ) {
308
309
var err error
309
310
switch action .GetVerb () {
310
311
case "create" :
@@ -320,7 +321,9 @@ func NewFakeOperator(ctx context.Context, options ...fakeOperatorOption) (*Opera
320
321
err = metadataFake .Resource (action .GetResource ()).Delete (context .TODO (), a .GetName (), metav1.DeleteOptions {})
321
322
}
322
323
return false , nil , err
323
- })
324
+ }
325
+ externalFake .PrependReactor ("*" , "*" , propagate )
326
+ apiextensionsFake .PrependReactor ("*" , "*" , propagate )
324
327
325
328
for _ , ns := range config .namespaces {
326
329
_ , err := config .operatorClient .KubernetesInterface ().CoreV1 ().Namespaces ().Create (context .TODO (), & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : ns }}, metav1.CreateOptions {})
@@ -4397,7 +4400,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4397
4400
operatorGroup * operatorsv1.OperatorGroup
4398
4401
csvs []* v1alpha1.ClusterServiceVersion
4399
4402
clientObjs []runtime.Object
4400
- crds []runtime. Object
4403
+ crds []* apiextensionsv1. CustomResourceDefinition
4401
4404
k8sObjs []runtime.Object
4402
4405
apis []runtime.Object
4403
4406
}
@@ -4474,7 +4477,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4474
4477
role ,
4475
4478
roleBinding ,
4476
4479
},
4477
- crds : []runtime. Object {crd },
4480
+ crds : []* apiextensionsv1. CustomResourceDefinition {crd },
4478
4481
},
4479
4482
expectedStatus : operatorsv1.OperatorGroupStatus {},
4480
4483
final : final {objects : map [string ][]runtime.Object {
@@ -4553,7 +4556,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4553
4556
role ,
4554
4557
roleBinding ,
4555
4558
},
4556
- crds : []runtime. Object {crd },
4559
+ crds : []* apiextensionsv1. CustomResourceDefinition {crd },
4557
4560
},
4558
4561
expectedStatus : operatorsv1.OperatorGroupStatus {
4559
4562
Namespaces : []string {operatorNamespace , targetNamespace },
@@ -4656,7 +4659,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4656
4659
role ,
4657
4660
roleBinding ,
4658
4661
},
4659
- crds : []runtime. Object {crd },
4662
+ crds : []* apiextensionsv1. CustomResourceDefinition {crd },
4660
4663
},
4661
4664
expectedStatus : operatorsv1.OperatorGroupStatus {
4662
4665
Namespaces : []string {operatorNamespace , targetNamespace },
@@ -4762,7 +4765,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4762
4765
role ,
4763
4766
roleBinding ,
4764
4767
},
4765
- crds : []runtime. Object {crd },
4768
+ crds : []* apiextensionsv1. CustomResourceDefinition {crd },
4766
4769
},
4767
4770
expectedStatus : operatorsv1.OperatorGroupStatus {
4768
4771
Namespaces : []string {corev1 .NamespaceAll },
@@ -4925,7 +4928,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4925
4928
role ,
4926
4929
roleBinding ,
4927
4930
},
4928
- crds : []runtime. Object {crd },
4931
+ crds : []* apiextensionsv1. CustomResourceDefinition {crd },
4929
4932
},
4930
4933
expectedStatus : operatorsv1.OperatorGroupStatus {
4931
4934
Namespaces : []string {corev1 .NamespaceAll },
@@ -4982,7 +4985,7 @@ func TestSyncOperatorGroups(t *testing.T) {
4982
4985
operatorGroup = tt .initial .operatorGroup .DeepCopy ()
4983
4986
clientObjs = copyObjs (append (tt .initial .clientObjs , operatorGroup ))
4984
4987
k8sObjs = copyObjs (tt .initial .k8sObjs )
4985
- extObjs = copyObjs ( tt . initial . crds )
4988
+ extObjs []runtime. Object
4986
4989
regObjs = copyObjs (tt .initial .apis )
4987
4990
)
4988
4991
@@ -4992,11 +4995,25 @@ func TestSyncOperatorGroups(t *testing.T) {
4992
4995
4993
4996
var partials []runtime.Object
4994
4997
for _ , csv := range tt .initial .csvs {
4995
- clientObjs = append (clientObjs , csv )
4998
+ clientObjs = append (clientObjs , csv . DeepCopy () )
4996
4999
partials = append (partials , & metav1.PartialObjectMetadata {
5000
+ TypeMeta : metav1.TypeMeta {
5001
+ Kind : "ClusterServiceVersion" ,
5002
+ APIVersion : v1alpha1 .SchemeGroupVersion .String (),
5003
+ },
4997
5004
ObjectMeta : csv .ObjectMeta ,
4998
5005
})
4999
5006
}
5007
+ for _ , crd := range tt .initial .crds {
5008
+ extObjs = append (extObjs , crd .DeepCopy ())
5009
+ partials = append (partials , & metav1.PartialObjectMetadata {
5010
+ TypeMeta : metav1.TypeMeta {
5011
+ Kind : "CustomResourceDefinition" ,
5012
+ APIVersion : apiextensionsv1 .SchemeGroupVersion .String (),
5013
+ },
5014
+ ObjectMeta : crd .ObjectMeta ,
5015
+ })
5016
+ }
5000
5017
l := logrus .New ()
5001
5018
l .SetLevel (logrus .DebugLevel )
5002
5019
l = l .WithField ("test" , tt .name ).Logger
@@ -5094,12 +5111,12 @@ func TestSyncOperatorGroups(t *testing.T) {
5094
5111
5095
5112
t .Log ("op.syncClusterServiceVersion" )
5096
5113
if err := op .syncClusterServiceVersion (& csv ); err != nil {
5097
- return false , err
5114
+ return false , fmt . Errorf ( "failed to syncClusterServiceVersion: %w" , err )
5098
5115
}
5099
5116
5100
5117
t .Log ("op.syncCopyCSV" )
5101
5118
if err := op .syncCopyCSV (& csv ); err != nil && ! tt .ignoreCopyError {
5102
- return false , err
5119
+ return false , fmt . Errorf ( "failed to syncCopyCSV: %w" , err )
5103
5120
}
5104
5121
}
5105
5122
0 commit comments