@@ -365,7 +365,7 @@ func (t *reconcileTarget[T]) Reconcile(ctx context.Context, component T) (bool,
365365 numManagedToBeDeleted := 0
366366 for _ , item := range status .Inventory {
367367 if item .Phase == PhaseScheduledForDeletion || item .Phase == PhaseScheduledForCompletion || item .Phase == PhaseDeleting || item .Phase == PhaseCompleting {
368- if t . isManaged (item , component ) {
368+ if isManaged (status . Inventory , item ) {
369369 numManagedToBeDeleted ++
370370 }
371371 }
@@ -394,7 +394,7 @@ func (t *reconcileTarget[T]) Reconcile(ctx context.Context, component T) (bool,
394394
395395 switch item .Phase {
396396 case PhaseScheduledForDeletion :
397- if numManagedToBeDeleted == 0 || t . isManaged (item , component ) {
397+ if numManagedToBeDeleted == 0 || isManaged (status . Inventory , item ) {
398398 if orphan {
399399 continue
400400 }
@@ -408,7 +408,7 @@ func (t *reconcileTarget[T]) Reconcile(ctx context.Context, component T) (bool,
408408 }
409409 numToBeDeleted ++
410410 case PhaseScheduledForCompletion :
411- if numManagedToBeDeleted == 0 || t . isManaged (item , component ) {
411+ if numManagedToBeDeleted == 0 || isManaged (status . Inventory , item ) {
412412 if orphan {
413413 return false , fmt .Errorf ("invalid usage of deletion policy: object %s is scheduled for completion (due to purge order) and therefore cannot be orphaned" , item )
414414 }
@@ -488,7 +488,7 @@ func (t *reconcileTarget[T]) Reconcile(ctx context.Context, component T) (bool,
488488 for j := k ; j < len (objects ) && getOrder (objects [j ]) == order ; j ++ {
489489 _object := objects [j ]
490490 _item := mustGetItem (status .Inventory , _object )
491- if _item .Phase != PhaseReady && _item .Phase != PhaseCompleted && ! t . isManaged (_object , component ) {
491+ if _item .Phase != PhaseReady && _item .Phase != PhaseCompleted && ! isManaged (status . Inventory , _object ) {
492492 // that means: _item.Phase is one of PhaseScheduledForApplication, PhaseCreating, PhaseUpdating
493493 numNotManagedToBeApplied ++
494494 }
@@ -497,7 +497,7 @@ func (t *reconcileTarget[T]) Reconcile(ctx context.Context, component T) (bool,
497497
498498 // for non-completed objects, compute and update status, and apply (create or update) the object if necessary
499499 if item .Phase != PhaseCompleted {
500- if numNotManagedToBeApplied == 0 || ! t . isManaged (object , component ) {
500+ if numNotManagedToBeApplied == 0 || ! isManaged (status . Inventory , object ) {
501501 // fetch object (if existing)
502502 existingObject , err := t .readObject (ctx , item )
503503 if err != nil {
@@ -583,7 +583,7 @@ func (t *reconcileTarget[T]) Delete(ctx context.Context, component T) (bool, err
583583 // count instances of managed types
584584 numManaged := 0
585585 for _ , item := range status .Inventory {
586- if t . isManaged (item , component ) {
586+ if isManaged (status . Inventory , item ) {
587587 numManaged ++
588588 }
589589 }
@@ -603,7 +603,7 @@ func (t *reconcileTarget[T]) Delete(ctx context.Context, component T) (bool, err
603603 continue
604604 }
605605
606- if numManaged == 0 || t . isManaged (item , component ) {
606+ if numManaged == 0 || isManaged (status . Inventory , item ) {
607607 // orphan the object, if according deletion policy is set
608608 if existingObject != nil {
609609 deletePolicy , err := t .getDeletePolicy (existingObject )
@@ -1034,16 +1034,3 @@ func (t *reconcileTarget[T]) isApiServiceUsed(ctx context.Context, apiService *a
10341034 }
10351035 return false , nil
10361036}
1037-
1038- func (t * reconcileTarget [T ]) isManaged (key types.TypeKey , component T ) bool {
1039- status := component .GetStatus ()
1040- gvk := key .GetObjectKind ().GroupVersionKind ()
1041- for _ , item := range status .Inventory {
1042- for _ , t := range item .ManagedTypes {
1043- if (t .Group == "*" || t .Group == gvk .Group ) && (t .Version == "*" || t .Version == gvk .Version ) && (t .Kind == "*" || t .Kind == gvk .Kind ) {
1044- return true
1045- }
1046- }
1047- }
1048- return false
1049- }
0 commit comments