@@ -24,6 +24,7 @@ import (
2424 "pkg.package-operator.run/boxcutter"
2525 "pkg.package-operator.run/boxcutter/machinery"
2626 machinerytypes "pkg.package-operator.run/boxcutter/machinery/types"
27+ "pkg.package-operator.run/boxcutter/ownerhandling"
2728 "pkg.package-operator.run/boxcutter/probing"
2829 ctrl "sigs.k8s.io/controller-runtime"
2930 "sigs.k8s.io/controller-runtime/pkg/builder"
@@ -141,7 +142,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, cer
141142 return c .delete (ctx , cer )
142143 }
143144
144- revision , opts , err := c .toBoxcutterRevision (ctx , cer )
145+ phases , opts , err := c .buildBoxcutterPhases (ctx , cer )
145146 if err != nil {
146147 setRetryingConditions (cer , err .Error ())
147148 return ctrl.Result {}, fmt .Errorf ("converting to boxcutter revision: %v" , err )
@@ -153,6 +154,14 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, cer
153154 return ctrl.Result {}, fmt .Errorf ("failed to create revision engine: %v" , err )
154155 }
155156
157+ revision := boxcutter .NewRevisionWithOwner (
158+ cer .Name ,
159+ cer .Spec .Revision ,
160+ phases ,
161+ cer ,
162+ ownerhandling .NewNative (c .Client .Scheme ()),
163+ )
164+
156165 if cer .Spec .LifecycleState == ocv1 .ClusterExtensionRevisionLifecycleStateArchived {
157166 if err := c .TrackingCache .Free (ctx , cer ); err != nil {
158167 markAsAvailableUnknown (cer , ocv1 .ClusterExtensionRevisionReasonReconciling , err .Error ())
@@ -171,7 +180,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, cer
171180 return ctrl.Result {}, werr
172181 }
173182
174- rres , err := revisionEngine .Reconcile (ctx , * revision , opts ... )
183+ rres , err := revisionEngine .Reconcile (ctx , revision , opts ... )
175184 if err != nil {
176185 if rres != nil {
177186 // Log detailed reconcile reports only in debug mode (V(1)) to reduce verbosity.
@@ -296,8 +305,8 @@ func (c *ClusterExtensionRevisionReconciler) delete(ctx context.Context, cer *oc
296305 return ctrl.Result {}, nil
297306}
298307
299- func (c * ClusterExtensionRevisionReconciler ) archive (ctx context.Context , revisionEngine RevisionEngine , cer * ocv1.ClusterExtensionRevision , revision * boxcutter.Revision ) (ctrl.Result , error ) {
300- tdres , err := revisionEngine .Teardown (ctx , * revision )
308+ func (c * ClusterExtensionRevisionReconciler ) archive (ctx context.Context , revisionEngine RevisionEngine , cer * ocv1.ClusterExtensionRevision , revision boxcutter.RevisionBuilder ) (ctrl.Result , error ) {
309+ tdres , err := revisionEngine .Teardown (ctx , revision )
301310 if err != nil {
302311 err = fmt .Errorf ("error archiving revision: %v" , err )
303312 setRetryingConditions (cer , err .Error ())
@@ -356,11 +365,11 @@ func (c *ClusterExtensionRevisionReconciler) SetupWithManager(mgr ctrl.Manager)
356365 Complete (c )
357366}
358367
359- func (c * ClusterExtensionRevisionReconciler ) establishWatch (ctx context.Context , cer * ocv1.ClusterExtensionRevision , revision * boxcutter.Revision ) error {
368+ func (c * ClusterExtensionRevisionReconciler ) establishWatch (ctx context.Context , cer * ocv1.ClusterExtensionRevision , revision boxcutter.RevisionBuilder ) error {
360369 gvks := sets .New [schema.GroupVersionKind ]()
361- for _ , phase := range revision .Phases {
362- for _ , obj := range phase .Objects {
363- gvks .Insert (obj .GroupVersionKind ())
370+ for _ , phase := range revision .GetPhases () {
371+ for _ , obj := range phase .GetObjects () {
372+ gvks .Insert (obj .GetObjectKind (). GroupVersionKind ())
364373 }
365374 }
366375
@@ -451,7 +460,7 @@ func (c *ClusterExtensionRevisionReconciler) listPreviousRevisions(ctx context.C
451460 return previous , nil
452461}
453462
454- func (c * ClusterExtensionRevisionReconciler ) toBoxcutterRevision (ctx context.Context , cer * ocv1.ClusterExtensionRevision ) (* boxcutter.Revision , []boxcutter.RevisionReconcileOption , error ) {
463+ func (c * ClusterExtensionRevisionReconciler ) buildBoxcutterPhases (ctx context.Context , cer * ocv1.ClusterExtensionRevision ) ([] boxcutter.Phase , []boxcutter.RevisionReconcileOption , error ) {
455464 previous , err := c .listPreviousRevisions (ctx , cer )
456465 if err != nil {
457466 return nil , nil , fmt .Errorf ("listing previous revisions: %w" , err )
@@ -473,13 +482,9 @@ func (c *ClusterExtensionRevisionReconciler) toBoxcutterRevision(ctx context.Con
473482 }),
474483 }
475484
476- r := & boxcutter.Revision {
477- Name : cer .Name ,
478- Owner : cer ,
479- Revision : cer .Spec .Revision ,
480- }
485+ phases := make ([]boxcutter.Phase , 0 )
481486 for _ , specPhase := range cer .Spec .Phases {
482- phase := boxcutter. Phase { Name : specPhase . Name }
487+ objs := make ([]client. Object , 0 )
483488 for _ , specObj := range specPhase .Objects {
484489 obj := specObj .Object .DeepCopy ()
485490
@@ -496,11 +501,11 @@ func (c *ClusterExtensionRevisionReconciler) toBoxcutterRevision(ctx context.Con
496501 obj , boxcutter .WithCollisionProtection (cp )))
497502 }
498503
499- phase . Objects = append (phase . Objects , * obj )
504+ objs = append (objs , obj )
500505 }
501- r . Phases = append (r . Phases , phase )
506+ phases = append (phases , boxcutter . NewPhase ( specPhase . Name , objs ) )
502507 }
503- return r , opts , nil
508+ return phases , opts , nil
504509}
505510
506511// EffectiveCollisionProtection resolves the collision protection value using
0 commit comments