@@ -16,13 +16,11 @@ import (
16
16
rbacv1 "k8s.io/api/rbac/v1"
17
17
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
18
18
apiextensionsfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake"
19
- "k8s.io/apimachinery/pkg/api/meta"
20
19
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
20
"k8s.io/apimachinery/pkg/runtime"
22
21
"k8s.io/apimachinery/pkg/types"
23
22
"k8s.io/client-go/informers"
24
23
k8sfake "k8s.io/client-go/kubernetes/fake"
25
- clitesting "k8s.io/client-go/testing"
26
24
"k8s.io/client-go/tools/cache"
27
25
"k8s.io/client-go/util/workqueue"
28
26
apiregistrationfake "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
@@ -34,6 +32,7 @@ import (
34
32
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler"
35
33
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver"
36
34
"github.com/operator-framework/operator-lifecycle-manager/pkg/fakes"
35
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/clientfake"
37
36
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
38
37
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
39
38
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
@@ -379,8 +378,6 @@ func TestSyncCatalogSources(t *testing.T) {
379
378
}
380
379
}
381
380
382
- // TODO: CatalogSource tests for RegistryServiceStatus
383
-
384
381
func TestCompetingCRDOwnersExist (t * testing.T ) {
385
382
386
383
testNamespace := "default"
@@ -465,43 +462,13 @@ func fakeConfigMapData() map[string]string {
465
462
return data
466
463
}
467
464
468
- // fakeClientOption configures a fake option
469
- type fakeClientOption func (fake.ClientsetDecorator )
470
-
471
- // withSelfLinks returns a fakeClientOption that configures a ClientsetDecorator to write selfLinks to all OLM types on create.
472
- func withSelfLinks (t * testing.T ) fakeClientOption {
473
- return func (c fake.ClientsetDecorator ) {
474
- c .PrependReactor ("create" , "*" , func (a clitesting.Action ) (bool , runtime.Object , error ) {
475
- ca , ok := a .(clitesting.CreateAction )
476
- if ! ok {
477
- t .Fatalf ("expected CreateAction" )
478
- }
479
-
480
- obj := ca .GetObject ()
481
- accessor , err := meta .Accessor (obj )
482
- if err != nil {
483
- return false , nil , err
484
- }
485
- if accessor .GetSelfLink () != "" {
486
- // SelfLink is already set
487
- return false , nil , nil
488
- }
489
-
490
- gvr := ca .GetResource ()
491
- accessor .SetSelfLink (buildSelfLink (gvr .GroupVersion ().String (), gvr .Resource , accessor .GetNamespace (), accessor .GetName ()))
492
-
493
- return false , obj , nil
494
- })
495
- }
496
- }
497
-
498
465
// fakeOperatorConfig is the configuration for a fake operator.
499
466
type fakeOperatorConfig struct {
500
- clientObjs []runtime.Object
501
- k8sObjs []runtime.Object
502
- extObjs []runtime.Object
503
- regObjs []runtime.Object
504
- fakeClientOptions []fakeClientOption
467
+ clientObjs []runtime.Object
468
+ k8sObjs []runtime.Object
469
+ extObjs []runtime.Object
470
+ regObjs []runtime.Object
471
+ clientOptions []clientfake. Option
505
472
}
506
473
507
474
// fakeOperatorOption applies an option to the given fake operator configuration.
@@ -525,9 +492,9 @@ func extObjs(extObjs ...runtime.Object) fakeOperatorOption {
525
492
}
526
493
}
527
494
528
- func withFakeClientOptions (options ... fakeClientOption ) fakeOperatorOption {
495
+ func withFakeClientOptions (options ... clientfake. Option ) fakeOperatorOption {
529
496
return func (config * fakeOperatorConfig ) {
530
- config .fakeClientOptions = options
497
+ config .clientOptions = options
531
498
}
532
499
}
533
500
@@ -540,11 +507,7 @@ func NewFakeOperator(namespace string, watchedNamespaces []string, stopCh <-chan
540
507
}
541
508
542
509
// Create client fakes
543
- clientFake := fake .NewReactionForwardingClientsetDecorator (config .clientObjs ... )
544
- for _ , option := range config .fakeClientOptions {
545
- option (clientFake )
546
- }
547
-
510
+ clientFake := fake .NewReactionForwardingClientsetDecorator (config .clientObjs , config .clientOptions ... )
548
511
opClientFake := operatorclient .NewClient (k8sfake .NewSimpleClientset (config .k8sObjs ... ), apiextensionsfake .NewSimpleClientset (config .extObjs ... ), apiregistrationfake .NewSimpleClientset (config .regObjs ... ))
549
512
550
513
// Create operator namespace
@@ -707,11 +670,3 @@ func toManifest(obj runtime.Object) string {
707
670
raw , _ := json .Marshal (obj )
708
671
return string (raw )
709
672
}
710
-
711
- // selfLink returns a selfLink.
712
- func buildSelfLink (groupVersion , plural , namespace , name string ) string {
713
- if namespace == metav1 .NamespaceAll {
714
- return fmt .Sprintf ("/apis/%s/%s/%s" , groupVersion , plural , name )
715
- }
716
- return fmt .Sprintf ("/apis/%s/namespaces/%s/%s/%s" , groupVersion , namespace , plural , name )
717
- }
0 commit comments