@@ -37,6 +37,7 @@ import (
3737
3838 trustapi "github.com/cert-manager/trust-manager/pkg/apis/trust/v1alpha1"
3939 "github.com/cert-manager/trust-manager/pkg/bundle/internal/ssa_client"
40+ "github.com/cert-manager/trust-manager/pkg/bundle/internal/target"
4041 "github.com/cert-manager/trust-manager/pkg/fspkg"
4142)
4243
@@ -67,10 +68,6 @@ type bundle struct {
6768 // a cache-backed Kubernetes client
6869 client client.Client
6970
70- // targetCache is a cache.Cache that holds cached ConfigMap and Secret
71- // resources that are used as targets for Bundles.
72- targetCache client.Reader
73-
7471 // defaultPackage holds the loaded 'default' certificate package, if one was specified
7572 // at startup.
7673 defaultPackage * fspkg.Package
@@ -84,9 +81,7 @@ type bundle struct {
8481 // Options holds options for the Bundle controller.
8582 Options
8683
87- // patchResourceOverwrite allows use to override the patchResource function
88- // it is used for testing purposes
89- patchResourceOverwrite func (ctx context.Context , obj interface {}) error
84+ targetReconciler * target.Reconciler
9085}
9186
9287// Reconcile is the top level function for reconciling over synced Bundles.
@@ -253,7 +248,7 @@ func (b *bundle) reconcileBundle(ctx context.Context, req ctrl.Request) (result
253248 Kind : string (kind ),
254249 },
255250 }
256- err := b .targetCache .List (ctx , targetList , & client.ListOptions {
251+ err := b .targetReconciler . Cache .List (ctx , targetList , & client.ListOptions {
257252 LabelSelector : labels .SelectorFromSet (map [string ]string {
258253 trustapi .BundleLabelKey : bundle .Name ,
259254 }),
@@ -303,12 +298,12 @@ func (b *bundle) reconcileBundle(ctx context.Context, req ctrl.Request) (result
303298
304299 if target .Kind == configMapTarget {
305300 syncFunc = func (targetLog logr.Logger , target targetResource , shouldExist bool ) (bool , error ) {
306- return b .syncConfigMapTarget (ctx , targetLog , & bundle , target .NamespacedName , resolvedBundle .targetData , shouldExist )
301+ return b .targetReconciler . SyncConfigMap (ctx , targetLog , & bundle , target .NamespacedName , resolvedBundle .Data , shouldExist )
307302 }
308303 }
309304 if target .Kind == secretTarget {
310305 syncFunc = func (targetLog logr.Logger , target targetResource , shouldExist bool ) (bool , error ) {
311- return b .syncSecretTarget (ctx , targetLog , & bundle , target .NamespacedName , resolvedBundle .targetData , shouldExist )
306+ return b .targetReconciler . SyncSecret (ctx , targetLog , & bundle , target .NamespacedName , resolvedBundle .Data , shouldExist )
312307 }
313308 }
314309
0 commit comments