@@ -32,8 +32,9 @@ import (
3232
3333 "github.com/sap/component-operator-runtime/internal/backoff"
3434 "github.com/sap/component-operator-runtime/internal/cluster"
35- "github.com/sap/component-operator-runtime/internal/kstatus"
3635 "github.com/sap/component-operator-runtime/pkg/manifests"
36+ "github.com/sap/component-operator-runtime/pkg/reconciler"
37+ "github.com/sap/component-operator-runtime/pkg/status"
3738 "github.com/sap/component-operator-runtime/pkg/types"
3839)
3940
@@ -77,11 +78,11 @@ type ReconcilerOptions struct {
7778 // How to react if a dependent object exists but has no or a different owner.
7879 // If unspecified, AdoptionPolicyIfUnowned is assumed.
7980 // Can be overridden by annotation on object level.
80- AdoptionPolicy * AdoptionPolicy
81+ AdoptionPolicy * reconciler. AdoptionPolicy
8182 // How to perform updates to dependent objects.
8283 // If unspecified, UpdatePolicyReplace is assumed.
8384 // Can be overridden by annotation on object level.
84- UpdatePolicy * UpdatePolicy
85+ UpdatePolicy * reconciler. UpdatePolicy
8586 // Schemebuilder allows to define additional schemes to be made available in the
8687 // target client.
8788 SchemeBuilder types.SchemeBuilder
@@ -93,7 +94,7 @@ type Reconciler[T Component] struct {
9394 id string
9495 client cluster.Client
9596 resourceGenerator manifests.Generator
96- statusAnalyzer kstatus .StatusAnalyzer
97+ statusAnalyzer status .StatusAnalyzer
9798 options ReconcilerOptions
9899 clients * cluster.ClientFactory
99100 backoff * backoff.Backoff
@@ -115,19 +116,21 @@ func NewReconciler[T Component](name string, resourceGenerator manifests.Generat
115116 options .CreateMissingNamespaces = ref (true )
116117 }
117118 if options .AdoptionPolicy == nil {
118- options .AdoptionPolicy = ref (AdoptionPolicyIfUnowned )
119+ options .AdoptionPolicy = ref (reconciler . AdoptionPolicyIfUnowned )
119120 }
120121 if options .UpdatePolicy == nil {
121- options .UpdatePolicy = ref (UpdatePolicyReplace )
122+ options .UpdatePolicy = ref (reconciler . UpdatePolicyReplace )
122123 }
123124
124125 return & Reconciler [T ]{
125126 name : name ,
126127 resourceGenerator : resourceGenerator ,
127- statusAnalyzer : kstatus .NewStatusAnalyzer (name ),
128- options : options ,
129- backoff : backoff .NewBackoff (10 * time .Second ),
130- postReadHooks : []HookFunc [T ]{resolveReferences [T ]},
128+ // TODO: make statusAnalyzer specifiable via options?
129+ statusAnalyzer : status .NewStatusAnalyzer (name ),
130+ options : options ,
131+ // TODO: make backoff configurable via options?
132+ backoff : backoff .NewBackoff (10 * time .Second ),
133+ postReadHooks : []HookFunc [T ]{resolveReferences [T ]},
131134 }
132135}
133136
@@ -248,7 +251,12 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
248251 if err != nil {
249252 return ctrl.Result {}, errors .Wrap (err , "error getting client for component" )
250253 }
251- target := newReconcileTarget [T ](r .name , r .id , targetClient , r .resourceGenerator , r .statusAnalyzer , * r .options .CreateMissingNamespaces , * r .options .AdoptionPolicy , * r .options .UpdatePolicy )
254+ target := newReconcileTarget [T ](r .name , r .id , targetClient , r .resourceGenerator , reconciler.ReconcilerOptions {
255+ CreateMissingNamespaces : r .options .CreateMissingNamespaces ,
256+ AdoptionPolicy : r .options .AdoptionPolicy ,
257+ UpdatePolicy : r .options .UpdatePolicy ,
258+ StatusAnalyzer : r .statusAnalyzer ,
259+ })
252260 hookCtx := newContext (ctx ).WithClient (targetClient )
253261
254262 // do the reconciliation
@@ -271,7 +279,7 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
271279 return ctrl.Result {}, errors .Wrapf (err , "error running pre-reconcile hook (%d)" , hookOrder )
272280 }
273281 }
274- ok , err := target .Reconcile (ctx , component )
282+ ok , err := target .Apply (ctx , component )
275283 if err != nil {
276284 log .V (1 ).Info ("error while reconciling dependent resources" )
277285 return ctrl.Result {}, errors .Wrap (err , "error reconciling dependent resources" )
0 commit comments