Skip to content

Commit

Permalink
fix handler.go
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 committed Jul 19, 2024
1 parent f6d8018 commit 0f80a5f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/controller/handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers

import (
"context"
"fmt"
"reflect"

Expand All @@ -19,13 +20,13 @@ import (
// enqueueRequestForJenkins enqueues a Request for Secrets and ConfigMaps created by jenkins-operator.
type enqueueRequestForJenkins struct{}

func (e *enqueueRequestForJenkins) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {
func (e *enqueueRequestForJenkins) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
if req := e.getOwnerReconcileRequests(evt.Object); req != nil {
q.Add(*req)
}
}

func (e *enqueueRequestForJenkins) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (e *enqueueRequestForJenkins) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
req1 := e.getOwnerReconcileRequests(evt.ObjectOld)
req2 := e.getOwnerReconcileRequests(evt.ObjectNew)

Expand All @@ -51,13 +52,13 @@ func (e *enqueueRequestForJenkins) Update(evt event.UpdateEvent, q workqueue.Rat
}
}

func (e *enqueueRequestForJenkins) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (e *enqueueRequestForJenkins) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
if req := e.getOwnerReconcileRequests(evt.Object); req != nil {
q.Add(*req)
}
}

func (e *enqueueRequestForJenkins) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {
func (e *enqueueRequestForJenkins) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
if req := e.getOwnerReconcileRequests(evt.Object); req != nil {
q.Add(*req)
}
Expand All @@ -79,24 +80,24 @@ type jenkinsDecorator struct {
handler handler.EventHandler
}

func (e *jenkinsDecorator) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {
func (e *jenkinsDecorator) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
log.Log.WithValues("cr", evt.Object.GetName()).Info(fmt.Sprintf("%T/%s was created", evt.Object, evt.Object.GetName()))
e.handler.Create(evt, q)
e.handler.Create(ctx, evt, q)
}

func (e *jenkinsDecorator) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
func (e *jenkinsDecorator) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
if !reflect.DeepEqual(evt.ObjectOld.(*v1alpha2.Jenkins).Spec, evt.ObjectNew.(*v1alpha2.Jenkins).Spec) {
log.Log.WithValues("cr", evt.ObjectNew.GetName()).Info(
fmt.Sprintf("%T/%s has been updated", evt.ObjectNew, evt.ObjectNew.GetName()))
}
e.handler.Update(evt, q)
e.handler.Update(ctx, evt, q)
}

func (e *jenkinsDecorator) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (e *jenkinsDecorator) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
log.Log.WithValues("cr", evt.Object.GetName()).Info(fmt.Sprintf("%T/%s was deleted", evt.Object, evt.Object.GetName()))
e.handler.Delete(evt, q)
e.handler.Delete(ctx, evt, q)
}

func (e *jenkinsDecorator) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {
e.handler.Generic(evt, q)
func (e *jenkinsDecorator) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
e.handler.Generic(ctx, evt, q)
}

0 comments on commit 0f80a5f

Please sign in to comment.