Skip to content

Commit

Permalink
Remove unrelated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Jan 28, 2025
1 parent 657cf29 commit 9687a8f
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions pkg/controller/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"

Expand All @@ -27,10 +26,6 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/types"
)

const (
finalizerName = "platform.opendatahub.io/finalizer"
)

// Reconciler provides generic reconciliation functionality for ODH objects.
type Reconciler struct {
Client *odhClient.Client
Expand Down Expand Up @@ -117,14 +112,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
if err := r.delete(ctx, res); err != nil {
return ctrl.Result{}, err
}
if err := r.removeFinalizer(ctx, res); err != nil {
return ctrl.Result{}, err
}
} else {
if err := r.addFinalizer(ctx, res); err != nil {
return ctrl.Result{}, err
}

if err := r.apply(ctx, res); err != nil {
return ctrl.Result{}, err
}
Expand All @@ -133,36 +121,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return ctrl.Result{}, nil
}

func (r *Reconciler) addFinalizer(ctx context.Context, res common.PlatformObject) error {
if len(r.Finalizer) == 0 {
return nil
}

if !controllerutil.AddFinalizer(res, finalizerName) {
return nil
}

err := r.Client.Update(ctx, res)
if err != nil {
return fmt.Errorf("failure adding finalizer %s: %w", finalizerName, err)
}

return nil
}

func (r *Reconciler) removeFinalizer(ctx context.Context, res common.PlatformObject) error {
if !controllerutil.RemoveFinalizer(res, finalizerName) {
return nil
}

err := r.Client.Update(ctx, res)
if err != nil {
return fmt.Errorf("failure removing finalizer %s: %w", finalizerName, err)
}

return nil
}

func (r *Reconciler) delete(ctx context.Context, res common.PlatformObject) error {
l := log.FromContext(ctx)
l.Info("delete")
Expand Down

0 comments on commit 9687a8f

Please sign in to comment.