@@ -26,6 +26,7 @@ import (
2626 utilerrors "k8s.io/apimachinery/pkg/util/errors"
2727 "k8s.io/klog/v2"
2828 "sigs.k8s.io/controller-runtime/pkg/cache"
29+ "sigs.k8s.io/controller-runtime/pkg/client"
2930
3031 kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2"
3132 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2/helpers"
@@ -40,15 +41,15 @@ type reconciler struct {
4041 getCRD func (ctx context.Context , cache cache.Cache , name string ) (* apiextensionsv1.CustomResourceDefinition , error )
4142 getAPIResourceSchema func (ctx context.Context , cache cache.Cache , name string ) (* kubebindv1alpha2.APIResourceSchema , error )
4243 getServiceExport func (ctx context.Context , cache cache.Cache , ns , name string ) (* kubebindv1alpha2.APIServiceExport , error )
43- createServiceExport func (ctx context.Context , resource * kubebindv1alpha2.APIServiceExport ) (* kubebindv1alpha2.APIServiceExport , error )
44- createAPIResourceSchema func (ctx context.Context , schema * kubebindv1alpha2.APIResourceSchema ) (* kubebindv1alpha2.APIResourceSchema , error )
45- deleteServiceExportRequest func (ctx context.Context , namespace , name string ) error
44+ createServiceExport func (ctx context.Context , cl client. Client , resource * kubebindv1alpha2.APIServiceExport ) (* kubebindv1alpha2.APIServiceExport , error )
45+ createAPIResourceSchema func (ctx context.Context , cl client. Client , schema * kubebindv1alpha2.APIResourceSchema ) (* kubebindv1alpha2.APIResourceSchema , error )
46+ deleteServiceExportRequest func (ctx context.Context , cl client. Client , namespace , name string ) error
4647}
4748
48- func (r * reconciler ) reconcile (ctx context.Context , cache cache.Cache , req * kubebindv1alpha2.APIServiceExportRequest ) error {
49+ func (r * reconciler ) reconcile (ctx context.Context , cl client. Client , cache cache.Cache , req * kubebindv1alpha2.APIServiceExportRequest ) error {
4950 var errs []error
5051
51- if err := r .ensureExports (ctx , cache , req ); err != nil {
52+ if err := r .ensureExports (ctx , cl , cache , req ); err != nil {
5253 errs = append (errs , err )
5354 }
5455
@@ -57,7 +58,7 @@ func (r *reconciler) reconcile(ctx context.Context, cache cache.Cache, req *kube
5758 return utilerrors .NewAggregate (errs )
5859}
5960
60- func (r * reconciler ) ensureExports (ctx context.Context , cache cache.Cache , req * kubebindv1alpha2.APIServiceExportRequest ) error {
61+ func (r * reconciler ) ensureExports (ctx context.Context , cl client. Client , cache cache.Cache , req * kubebindv1alpha2.APIServiceExportRequest ) error {
6162 logger := klog .FromContext (ctx )
6263
6364 if req .Status .Phase == kubebindv1alpha2 .APIServiceExportRequestPhasePending {
@@ -93,7 +94,7 @@ func (r *reconciler) ensureExports(ctx context.Context, cache cache.Cache, req *
9394 schema .Namespace = req .Namespace
9495
9596 logger .V (1 ).Info ("Creating APIResourceSchema" , "name" , schema .Name , "namespace" , schema .Namespace )
96- if apiResourceSchema , err = r .createAPIResourceSchema (ctx , schema ); err != nil {
97+ if apiResourceSchema , err = r .createAPIResourceSchema (ctx , cl , schema ); err != nil {
9798 return err
9899 }
99100 case err != nil :
@@ -130,7 +131,7 @@ func (r *reconciler) ensureExports(ctx context.Context, cache cache.Cache, req *
130131 }
131132
132133 logger .V (1 ).Info ("Creating APIServiceExport" , "name" , export .Name , "namespace" , export .Namespace )
133- if _ , err = r .createServiceExport (ctx , export ); err != nil {
134+ if _ , err = r .createServiceExport (ctx , cl , export ); err != nil {
134135 return err
135136 }
136137 }
@@ -151,7 +152,7 @@ func (r *reconciler) ensureExports(ctx context.Context, cache cache.Cache, req *
151152
152153 if time .Since (req .CreationTimestamp .Time ) > 10 * time .Minute {
153154 logger .Info ("Deleting service binding request %s/%s" , req .Namespace , req .Name , "reason" , "timeout" , "age" , time .Since (req .CreationTimestamp .Time ))
154- return r .deleteServiceExportRequest (ctx , req .Namespace , req .Name )
155+ return r .deleteServiceExportRequest (ctx , cl , req .Namespace , req .Name )
155156 }
156157
157158 return nil
0 commit comments