mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
Add path component to finalizer (#202)
The Kubernetes client warns about not having a path component in the finalizer. This change adds a unqiue path component for each reconciler kind.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package k8sutil
|
||||
|
||||
const NetbirdFinalizer = "finalizers.netbird.io"
|
||||
|
||||
func Finalizer(kind string) string {
|
||||
return NetbirdFinalizer + "/" + kind
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package k8sutil
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user