reconcile: allow cfg of manager in atomic action

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
This commit is contained in:
Hidde Beydals 2023-10-31 18:06:24 +01:00
parent ac9c2c3142
commit f156c3550e
No known key found for this signature in database
GPG Key ID: 979F380FC2341744
3 changed files with 7 additions and 5 deletions

View File

@ -328,7 +328,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
}
// Off we go!
if err = intreconcile.NewAtomicRelease(patchHelper, cfg, r.EventRecorder).Reconcile(ctx, &intreconcile.Request{
if err = intreconcile.NewAtomicRelease(patchHelper, cfg, r.EventRecorder, r.FieldManager).Reconcile(ctx, &intreconcile.Request{
Object: obj,
Chart: loadedChart,
Values: values,

View File

@ -80,16 +80,18 @@ type AtomicRelease struct {
configFactory *action.ConfigFactory
eventRecorder record.EventRecorder
strategy releaseStrategy
fieldManager string
}
// NewAtomicRelease returns a new AtomicRelease reconciler configured with the
// provided values.
func NewAtomicRelease(patchHelper *patch.SerialPatcher, cfg *action.ConfigFactory, recorder record.EventRecorder) *AtomicRelease {
func NewAtomicRelease(patchHelper *patch.SerialPatcher, cfg *action.ConfigFactory, recorder record.EventRecorder, fieldManager string) *AtomicRelease {
return &AtomicRelease{
patchHelper: patchHelper,
eventRecorder: recorder,
configFactory: cfg,
strategy: &cleanReleaseStrategy{},
fieldManager: fieldManager,
}
}
@ -188,7 +190,7 @@ func (r *AtomicRelease) Reconcile(ctx context.Context, req *Request) error {
conditions.MarkTrue(req.Object, meta.ReconcilingCondition, "Progressing", "Running '%s' %s action with timeout of %s",
next.Name(), next.Type(), timeoutForAction(next, req.Object).String())
// Patch the object to reflect the new condition.
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner("helm-controller")); err != nil {
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil {
return err
}
@ -214,7 +216,7 @@ func (r *AtomicRelease) Reconcile(ctx context.Context, req *Request) error {
previous = append(previous, next.Type())
// Patch the release to reflect progress.
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner("helm-controller")); err != nil {
if err = r.patchHelper.Patch(ctx, req.Object, patch.WithOwnedConditions{Conditions: OwnedConditions}, patch.WithFieldOwner(r.fieldManager)); err != nil {
return err
}
}

View File

@ -163,7 +163,7 @@ func TestAtomicRelease_Reconcile(t *testing.T) {
Chart: testutil.BuildChart(testutil.ChartWithTestHook()),
Values: nil,
}
g.Expect(NewAtomicRelease(patchHelper, cfg, recorder).Reconcile(context.TODO(), req)).ToNot(HaveOccurred())
g.Expect(NewAtomicRelease(patchHelper, cfg, recorder, "helm-controller").Reconcile(context.TODO(), req)).ToNot(HaveOccurred())
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions([]metav1.Condition{
{