func (c *Finalizer) IsDeletionCandidate(resource finalizable) bool {
	return resource.GetDeletionTimestamp() != nil && c.getIndex(resource) != -1
}
IsDeletionCandidate checks if the resource is a candidate for deletion
package k8s
import (
	"github.com/operator-framework/operator-sdk/pkg/sdk"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type finalizable interface {
	sdk.Object
	GetFinalizers() []string
	SetFinalizers(finalizers []string)
	GetDeletionTimestamp() *metav1.Time
}
type Finalizer struct {
	driver Client
	value  string
}
func NewFinalizer(driver Client, finalizerValue string) *Finalizer {
	return &Finalizer{
		driver: driver,
		value:  finalizerValue,
	}
}
func (c *Finalizer) Add(resource finalizable) error {
	finalizers := append(resource.GetFinalizers(), c.value)
	resource.SetFinalizers(finalizers)
	clone := resource.DeepCopyObject()
	return c.driver.Update(clone)
}
func (c *Finalizer) Remove(resource finalizable) error {
	finalizers := resource.GetFinalizers()
	for idx, finalizer := range finalizers {
		if finalizer == c.value {
			finalizers = append(finalizers[:idx], finalizers[idx+1:]...)
			break
		}
	}
	resource.SetFinalizers(finalizers)
	clone := resource.DeepCopyObject()
	return c.driver.Update(clone)
}