From 233c497f5c28a7c8980e62df3106ac7fee4720d7 Mon Sep 17 00:00:00 2001 From: ssttehrani Date: Sat, 6 Apr 2024 17:51:04 +0330 Subject: [PATCH] chore: fix linting issues --- internal/controller/service/controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/controller/service/controller.go b/internal/controller/service/controller.go index c27cff8..83981dd 100644 --- a/internal/controller/service/controller.go +++ b/internal/controller/service/controller.go @@ -245,9 +245,11 @@ func (re *ReconcilerExtended) addFinalizer(ctx context.Context) (*ctrl.Result, e if err := re.Client.Get(ctx, re.request.NamespacedName, re.service); err != nil { return err } + if controllerutil.ContainsFinalizer(re.service, consts.ServiceFinalizerString) { return nil } + controllerutil.AddFinalizer(re.service, consts.ServiceFinalizerString) return re.Client.Update(ctx, re.service) @@ -268,9 +270,11 @@ func (re *ReconcilerExtended) removeFinalizer(ctx context.Context) (*ctrl.Result if err := re.Client.Get(ctx, re.request.NamespacedName, re.service); err != nil { return err } + if !controllerutil.ContainsFinalizer(re.service, consts.ServiceFinalizerString) { return nil } + controllerutil.RemoveFinalizer(re.service, consts.ServiceFinalizerString) return re.Client.Update(ctx, re.service)