Skip to content

Commit cf118f0

Browse files
committed
add reconciler name to hook context
1 parent 1374c13 commit cf118f0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/component/reconciler.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
// TODO: allow some timeout feature, such that component will go into error state if not ready within the given timeout
4747
// (e.g. through a TimeoutConfiguration interface that components could optionally implement)
4848
// TODO: from time to time, enforce dependent updates even if digest is matching
49+
// (this might require a lastAppliedAt timestamp per inventory item)
4950
// TODO: run admission webhooks (if present) in reconcile (e.g. as post-read hook)
5051
// TODO: improve overall log output
5152

@@ -157,6 +158,7 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
157158
}
158159
return ctrl.Result{}, errors.Wrap(err, "unexpected get error")
159160
}
161+
// TODO: popuplate component's TypeMeta
160162

161163
// convenience accessors
162164
status := component.GetStatus()
@@ -240,8 +242,11 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
240242

241243
// run post-read hooks
242244
// note: it's important that this happens after deferring the status handler
245+
// TODO: enhance ctx with tailored logger and event recorder
246+
// TODO: enhance ctx with the local client
247+
hookCtx := newContext(ctx).WithReconcilerName(r.name)
243248
for hookOrder, hook := range r.postReadHooks {
244-
if err := hook(ctx, r.client, component); err != nil {
249+
if err := hook(hookCtx, r.client, component); err != nil {
245250
return ctrl.Result{}, errors.Wrapf(err, "error running post-read hook (%d)", hookOrder)
246251
}
247252
}
@@ -257,7 +262,9 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
257262
UpdatePolicy: r.options.UpdatePolicy,
258263
StatusAnalyzer: r.statusAnalyzer,
259264
})
260-
hookCtx := newContext(ctx).WithClient(targetClient)
265+
// TODO: enhance ctx with tailored logger and event recorder
266+
// TODO: enhance ctx with the local client
267+
hookCtx = newContext(ctx).WithReconcilerName(r.name).WithClient(targetClient)
261268

262269
// do the reconciliation
263270
if component.GetDeletionTimestamp().IsZero() {

pkg/component/target.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func (t *reconcileTarget[T]) Apply(ctx context.Context, component T) (bool, erro
5151
status := component.GetStatus()
5252
componentDigest := calculateComponentDigest(component)
5353

54+
// TODO: enhance ctx with local client
5455
generateCtx := newContext(ctx).
5556
WithReconcilerName(t.reconcilerName).
5657
WithClient(t.client).

0 commit comments

Comments
 (0)