Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/common/billing_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func CreateOrUpdateBillingServiceWithOptions(ctx context.Context, svc *runtime.S
Controller: ptr.To(true),
BlockOwnerDeletion: ptr.To(false),
}
kubeOpts = append(kubeOpts, runtime.KubeOptionSetOwnerReferenceFromKubeObject(billingService, ownerRef))
kubeOpts = append(kubeOpts, runtime.KubeOptionSetOwnerReferenceFromKubeObject(ownerRef))
}

// Set the BillingService as a desired kube object
Expand Down
10 changes: 7 additions & 3 deletions pkg/comp-functions/runtime/function_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,14 @@ func KubeOptionObserveCreateUpdate(obj *xkube.Object) {
obj.Spec.ManagementPolicies = append(obj.Spec.ManagementPolicies, xpv1.ManagementActionCreate, xpv1.ManagementActionUpdate, xpv1.ManagementActionObserve)
}

// KubeOptionSetOwnerReferenceFromKubeObject sets the owner reference from kube object to resource
func KubeOptionSetOwnerReferenceFromKubeObject(res client.Object, ownerRef metav1.OwnerReference) KubeObjectOption {
// KubeOptionSetOwnerReferenceFromKubeObject sets the owner reference on the manifest inside the kube object.
func KubeOptionSetOwnerReferenceFromKubeObject(ownerRef metav1.OwnerReference) KubeObjectOption {
return func(obj *xkube.Object) {
res.SetOwnerReferences([]metav1.OwnerReference{ownerRef})
u, ok := obj.Spec.ForProvider.Manifest.Object.(*unstructured.Unstructured)
if !ok {
return
}
u.SetOwnerReferences(append(u.GetOwnerReferences(), ownerRef))
}
}

Expand Down
Loading