Skip to content

Commit 433883b

Browse files
authored
Rename hasOwner to ownedByEnvironment (#542)
Default to always checking Kind Environment instead of passing a resource in. This function is not used by any other controller or to check anything but environment, so might as well
1 parent e5e4f85 commit 433883b

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

internal/controller/executionspace_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *ExecutionSpaceReconciler) Reconcile(ctx context.Context, req ctrl.Reque
6363
}
6464

6565
// Ownership handoff: If Environment owns this ExecutionSpace, we relinquish control
66-
if hasOwner(executionSpace.OwnerReferences, "Environment") {
66+
if ownedByEnvironment(executionSpace.OwnerReferences) {
6767
if controllerutil.ContainsFinalizer(executionSpace, providerFinalizer) {
6868
// Clean up our finalizer since the environment controller now owns the ExecutionSpace
6969
controllerutil.RemoveFinalizer(executionSpace, providerFinalizer)

internal/controller/iut_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *IutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
6363
}
6464

6565
// Ownership handoff: If Environment owns this IUT, we relinquish control
66-
if hasOwner(iut.OwnerReferences, "Environment") {
66+
if ownedByEnvironment(iut.OwnerReferences) {
6767
if controllerutil.ContainsFinalizer(iut, providerFinalizer) {
6868
// Clean up our finalizer since the environment controller now owns the IUT.
6969
controllerutil.RemoveFinalizer(iut, providerFinalizer)

internal/controller/logarea_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *LogAreaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
6363
}
6464

6565
// Ownership handoff: If Environment owns this LogArea, we relinquish control
66-
if hasOwner(logarea.OwnerReferences, "Environment") {
66+
if ownedByEnvironment(logarea.OwnerReferences) {
6767
if controllerutil.ContainsFinalizer(logarea, providerFinalizer) {
6868
// Clean up our finalizer since the environment controller now owns the LogArea.
6969
controllerutil.RemoveFinalizer(logarea, providerFinalizer)

internal/controller/utilities.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ const (
4747
providerFinalizer = "etos.eiffel-community.github.io/managed-by-provider"
4848
)
4949

50-
// hasOwner checks if a resource kind exists in ownerReferences.
51-
func hasOwner(ownerReferences []metav1.OwnerReference, kind string) bool {
50+
// ownedByEnvironment checks if an Environment resource exists in ownerReferences.
51+
func ownedByEnvironment(ownerReferences []metav1.OwnerReference) bool {
52+
kind := "Environment"
5253
for _, ownerReference := range ownerReferences {
5354
if ownerReference.Kind == kind {
5455
return true

0 commit comments

Comments
 (0)