From 7b45316e5b93d51e55c14f0d0d22ab9e6feddcf1 Mon Sep 17 00:00:00 2001 From: fahed dorgaa Date: Mon, 8 Nov 2021 12:49:03 +0100 Subject: [PATCH] add NewNopFinalizer Signed-off-by: fahed dorgaa --- pkg/resource/api.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/resource/api.go b/pkg/resource/api.go index 7c77e2a..5ec9062 100644 --- a/pkg/resource/api.go +++ b/pkg/resource/api.go @@ -210,6 +210,18 @@ type APIFinalizer struct { finalizer string } +// NewNopFinalizer returns a Finalizer that does nothing. +func NewNopFinalizer() Finalizer { return nopFinalizer{} } + +type nopFinalizer struct{} + +func (f nopFinalizer) AddFinalizer(ctx context.Context, obj Object) error { + return nil +} +func (f nopFinalizer) RemoveFinalizer(ctx context.Context, obj Object) error { + return nil +} + // NewAPIFinalizer returns a new APIFinalizer. func NewAPIFinalizer(c client.Client, finalizer string) *APIFinalizer { return &APIFinalizer{client: c, finalizer: finalizer}