Skip to content

Commit

Permalink
added isownedby fn
Browse files Browse the repository at this point in the history
  • Loading branch information
henderiw committed May 19, 2024
1 parent 6e817b8 commit 9df3bdc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions apis/backend/infra/v1alpha1/endpoint_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion apis/backend/infra/v1alpha1/link_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,4 @@ func (r *Link) GetUserDefinedLabels() map[string]string {

func (r *Link) GetProvider() string {
return ""
}
}

0 comments on commit 9df3bdc

Please sign in to comment.