From 029756dc529092251ef15035d4aaf2cd89dabdc2 Mon Sep 17 00:00:00 2001
From: Martin Schuppert <mschuppert@redhat.com>
Date: Mon, 17 Jun 2024 10:37:03 +0200
Subject: [PATCH] Align finalizer with Custom Resource Definition doc

Per Custom Resource Definition docs [1], custom finalizer names
are expected to be in format "consist of a domain name, a forward
slash and the name of the finalizer" (e.g. foo.bar/name).

This aligns the finalizer provided by the helper to follow this
definition and uses openstack.org/<gkv.kind> (all lower case) as the
finalizer.

[1] https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#finalizers:~:text=Identifiers%20of%20custom%20finalizers%20consist%20of%20a%20domain%20name%2C%20a%20forward%20slash%20and%20the%20name%20of%20the%20finalizer

Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
---
 modules/common/helper/helper.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/modules/common/helper/helper.go b/modules/common/helper/helper.go
index 7c155d66..862f969d 100644
--- a/modules/common/helper/helper.go
+++ b/modules/common/helper/helper.go
@@ -19,6 +19,7 @@ package helper
 import (
 	"context"
 	"encoding/json"
+	"strings"
 
 	"github.com/go-logr/logr"
 	"github.com/pkg/errors"
@@ -72,7 +73,7 @@ func NewHelper(obj client.Object, crClient client.Client, kclient kubernetes.Int
 		before:       unstructuredObj,
 		beforeObject: obj.DeepCopyObject().(client.Object),
 		logger:       log,
-		finalizer:    gvk.Kind,
+		finalizer:    strings.ToLower("openstack.org/" + gvk.Kind),
 	}, nil
 }