mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 18:59:09 +00:00
We dont want to promote the use of the "old" resources with NB prefix so the Gateway API integration should only support the new ones. --------- Signed-off-by: Philip Laine <philip.laine@gmail.com>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
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 ControllerReference(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
|
|
}
|
|
|
|
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(false).
|
|
WithBlockOwnerDeletion(false), nil
|
|
}
|