From 9df3bdc4b07253030b64217c46b690fe4d73f424 Mon Sep 17 00:00:00 2001 From: Wim Henderickx Date: Sun, 19 May 2024 20:15:27 +0200 Subject: [PATCH] added isownedby fn --- apis/backend/infra/v1alpha1/endpoint_interface.go | 13 +++++++++++++ apis/backend/infra/v1alpha1/link_interface.go | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apis/backend/infra/v1alpha1/endpoint_interface.go b/apis/backend/infra/v1alpha1/endpoint_interface.go index 27dad09..2bb99f7 100644 --- a/apis/backend/infra/v1alpha1/endpoint_interface.go +++ b/apis/backend/infra/v1alpha1/endpoint_interface.go @@ -384,3 +384,16 @@ func (r *Endpoint) IsClaimed(cr client.Object) OwnerStatus { } return Free } + +func (r *Endpoint) IsOwnedBy(cr client.Object) bool { + refs := r.GetOwnerReferences() + for _, ref := range refs { + if ref.APIVersion == cr.GetObjectKind().GroupVersionKind().GroupVersion().String() && + ref.Kind == cr.GetObjectKind().GroupVersionKind().Kind { + if ref.UID == cr.GetUID() && ref.Name == cr.GetName() { + return true + } + } + } + return false +} diff --git a/apis/backend/infra/v1alpha1/link_interface.go b/apis/backend/infra/v1alpha1/link_interface.go index 3b74dd3..e97b20c 100644 --- a/apis/backend/infra/v1alpha1/link_interface.go +++ b/apis/backend/infra/v1alpha1/link_interface.go @@ -350,4 +350,4 @@ func (r *Link) GetUserDefinedLabels() map[string]string { func (r *Link) GetProvider() string { return "" -} \ No newline at end of file +}