Skip to content

Commit

Permalink
fix(controller): inspect all references (#606)
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Bähler <[email protected]>
  • Loading branch information
oliverbaehler authored Jan 10, 2025
1 parent f2c393e commit c338410
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/controllers/watchdog/namespaced_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
capsuleutils "github.com/projectcapsule/capsule/pkg/utils"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -86,11 +87,16 @@ func (c *NamespacedWatcher) SetupWithManager(mgr manager.Manager, gvk metav1.Gro
ns := corev1.Namespace{}
_ = c.Client.Get(context.Background(), types.NamespacedName{Name: object.GetNamespace()}, &ns)

if len(ns.GetOwnerReferences()) > 0 && ns.GetOwnerReferences()[0].Kind == "Tenant" {
return true
tenancy := false
for _, objectRef := range ns.ObjectMeta.OwnerReferences {
if capsuleutils.IsTenantOwnerReference(objectRef) {
tenancy = true

break
}
}

return false
return tenancy
}))).
Complete(c)
}

0 comments on commit c338410

Please sign in to comment.