mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
23 lines
647 B
Go
23 lines
647 B
Go
package ssautil
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"k8s.io/apimachinery/pkg/runtime"
|
||
|
|
metav1ac "k8s.io/client-go/applyconfigurations/meta/v1"
|
||
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||
|
|
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
|
||
|
|
)
|
||
|
|
|
||
|
|
func OwnerReference(owner client.Object, scheme *runtime.Scheme) (*metav1ac.OwnerReferenceApplyConfiguration, error) {
|
||
|
|
gvk, err := apiutil.GVKForObject(owner, scheme)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return metav1ac.OwnerReference().
|
||
|
|
WithAPIVersion(gvk.GroupVersion().String()).
|
||
|
|
WithKind(gvk.Kind).
|
||
|
|
WithName(owner.GetName()).
|
||
|
|
WithUID(owner.GetUID()).
|
||
|
|
WithController(true).
|
||
|
|
WithBlockOwnerDeletion(true), nil
|
||
|
|
}
|