@@ -16,13 +16,11 @@ import (
1616 rbacv1 "k8s.io/api/rbac/v1"
1717 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
1818 apiextensionsfake "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake"
19- "k8s.io/apimachinery/pkg/api/meta"
2019 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2120 "k8s.io/apimachinery/pkg/runtime"
2221 "k8s.io/apimachinery/pkg/types"
2322 "k8s.io/client-go/informers"
2423 k8sfake "k8s.io/client-go/kubernetes/fake"
25- clitesting "k8s.io/client-go/testing"
2624 "k8s.io/client-go/tools/cache"
2725 "k8s.io/client-go/util/workqueue"
2826 apiregistrationfake "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
@@ -34,6 +32,7 @@ import (
3432 "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler"
3533 "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver"
3634 "github.com/operator-framework/operator-lifecycle-manager/pkg/fakes"
35+ "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/clientfake"
3736 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
3837 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
3938 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
@@ -379,8 +378,6 @@ func TestSyncCatalogSources(t *testing.T) {
379378 }
380379}
381380
382- // TODO: CatalogSource tests for RegistryServiceStatus
383-
384381func TestCompetingCRDOwnersExist (t * testing.T ) {
385382
386383 testNamespace := "default"
@@ -465,43 +462,13 @@ func fakeConfigMapData() map[string]string {
465462 return data
466463}
467464
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-
498465// fakeOperatorConfig is the configuration for a fake operator.
499466type 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
505472}
506473
507474// fakeOperatorOption applies an option to the given fake operator configuration.
@@ -525,9 +492,9 @@ func extObjs(extObjs ...runtime.Object) fakeOperatorOption {
525492 }
526493}
527494
528- func withFakeClientOptions (options ... fakeClientOption ) fakeOperatorOption {
495+ func withFakeClientOptions (options ... clientfake. Option ) fakeOperatorOption {
529496 return func (config * fakeOperatorConfig ) {
530- config .fakeClientOptions = options
497+ config .clientOptions = options
531498 }
532499}
533500
@@ -540,11 +507,7 @@ func NewFakeOperator(namespace string, watchedNamespaces []string, stopCh <-chan
540507 }
541508
542509 // 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 ... )
548511 opClientFake := operatorclient .NewClient (k8sfake .NewSimpleClientset (config .k8sObjs ... ), apiextensionsfake .NewSimpleClientset (config .extObjs ... ), apiregistrationfake .NewSimpleClientset (config .regObjs ... ))
549512
550513 // Create operator namespace
@@ -707,11 +670,3 @@ func toManifest(obj runtime.Object) string {
707670 raw , _ := json .Marshal (obj )
708671 return string (raw )
709672}
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