mirror of
https://github.com/jenkinsci/kubernetes-operator.git
synced 2026-10-18 05:54:47 +02:00
update to go1.24
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/event"
|
||||
"sigs.k8s.io/controller-runtime/pkg/handler"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
@@ -20,13 +21,15 @@ import (
|
||||
// enqueueRequestForJenkins enqueues a Request for Secrets and ConfigMaps created by jenkins-operator.
|
||||
type enqueueRequestForJenkins struct{}
|
||||
|
||||
func (e *enqueueRequestForJenkins) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
|
||||
var _ handler.TypedEventHandler[client.Object, reconcile.Request] = &enqueueRequestForJenkins{}
|
||||
|
||||
func (e *enqueueRequestForJenkins) Create(ctx context.Context, evt event.TypedCreateEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
if req := e.getOwnerReconcileRequests(ctx, evt.Object); req != nil {
|
||||
q.Add(*req)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *enqueueRequestForJenkins) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *enqueueRequestForJenkins) Update(ctx context.Context, evt event.TypedUpdateEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
req1 := e.getOwnerReconcileRequests(ctx, evt.ObjectOld)
|
||||
req2 := e.getOwnerReconcileRequests(ctx, evt.ObjectNew)
|
||||
|
||||
@@ -52,13 +55,13 @@ func (e *enqueueRequestForJenkins) Update(ctx context.Context, evt event.UpdateE
|
||||
}
|
||||
}
|
||||
|
||||
func (e *enqueueRequestForJenkins) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *enqueueRequestForJenkins) Delete(ctx context.Context, evt event.TypedDeleteEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
if req := e.getOwnerReconcileRequests(ctx, evt.Object); req != nil {
|
||||
q.Add(*req)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *enqueueRequestForJenkins) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *enqueueRequestForJenkins) Generic(ctx context.Context, evt event.TypedGenericEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
if req := e.getOwnerReconcileRequests(ctx, evt.Object); req != nil {
|
||||
q.Add(*req)
|
||||
}
|
||||
@@ -77,15 +80,17 @@ func (e *enqueueRequestForJenkins) getOwnerReconcileRequests(_ context.Context,
|
||||
}
|
||||
|
||||
type jenkinsDecorator struct {
|
||||
handler handler.EventHandler
|
||||
handler handler.TypedEventHandler[client.Object, reconcile.Request]
|
||||
}
|
||||
|
||||
func (e *jenkinsDecorator) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
|
||||
var _ handler.TypedEventHandler[client.Object, reconcile.Request] = &jenkinsDecorator{}
|
||||
|
||||
func (e *jenkinsDecorator) Create(ctx context.Context, evt event.TypedCreateEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
log.Log.WithValues("cr", evt.Object.GetName()).Info(fmt.Sprintf("%T/%s was created", evt.Object, evt.Object.GetName()))
|
||||
e.handler.Create(ctx, evt, q)
|
||||
}
|
||||
|
||||
func (e *jenkinsDecorator) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *jenkinsDecorator) Update(ctx context.Context, evt event.TypedUpdateEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
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()))
|
||||
@@ -93,11 +98,11 @@ func (e *jenkinsDecorator) Update(ctx context.Context, evt event.UpdateEvent, q
|
||||
e.handler.Update(ctx, evt, q)
|
||||
}
|
||||
|
||||
func (e *jenkinsDecorator) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *jenkinsDecorator) Delete(ctx context.Context, evt event.TypedDeleteEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
log.Log.WithValues("cr", evt.Object.GetName()).Info(fmt.Sprintf("%T/%s was deleted", evt.Object, evt.Object.GetName()))
|
||||
e.handler.Delete(ctx, evt, q)
|
||||
}
|
||||
|
||||
func (e *jenkinsDecorator) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
|
||||
func (e *jenkinsDecorator) Generic(ctx context.Context, evt event.TypedGenericEvent[client.Object], q workqueue.TypedRateLimitingInterface[reconcile.Request]) {
|
||||
e.handler.Generic(ctx, evt, q)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package controllers
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
@@ -200,13 +199,11 @@ func (r *JenkinsReconciler) Reconcile(_ context.Context, request ctrl.Request) (
|
||||
[]string{fmt.Sprintf("%s Source '%s' Name '%s' groovy script execution failed, logs: %+v", groovyErr.ConfigurationType, groovyErr.Source, groovyErr.Name, groovyErr.Logs)}...,
|
||||
),
|
||||
}
|
||||
return reconcile.Result{Requeue: false}, nil
|
||||
return reconcile.Result{}, nil
|
||||
}
|
||||
return reconcile.Result{Requeue: true}, nil
|
||||
}
|
||||
if result.Requeue && result.RequeueAfter == 0 {
|
||||
result.RequeueAfter = time.Duration(rand.Intn(10)) * time.Second
|
||||
return reconcile.Result{RequeueAfter: time.Second}, nil
|
||||
}
|
||||
// Random delay logic removed as result.Requeue is deprecated
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -265,11 +262,11 @@ func (r *JenkinsReconciler) reconcile(request reconcile.Request) (reconcile.Resu
|
||||
if err != nil {
|
||||
return reconcile.Result{}, jenkins, err
|
||||
}
|
||||
if result.Requeue {
|
||||
if result.RequeueAfter > 0 {
|
||||
return result, jenkins, nil
|
||||
}
|
||||
if jenkinsClient == nil {
|
||||
return reconcile.Result{Requeue: false}, jenkins, nil
|
||||
return reconcile.Result{}, jenkins, nil
|
||||
}
|
||||
|
||||
if jenkins.Status.BaseConfigurationCompletedTime == nil {
|
||||
@@ -320,7 +317,7 @@ func (r *JenkinsReconciler) reconcile(request reconcile.Request) (reconcile.Resu
|
||||
if err != nil {
|
||||
return reconcile.Result{}, jenkins, err
|
||||
}
|
||||
if result.Requeue {
|
||||
if result.RequeueAfter > 0 {
|
||||
return result, jenkins, nil
|
||||
}
|
||||
|
||||
@@ -329,7 +326,7 @@ func (r *JenkinsReconciler) reconcile(request reconcile.Request) (reconcile.Resu
|
||||
if err != nil {
|
||||
return reconcile.Result{}, jenkins, err
|
||||
}
|
||||
if result.Requeue {
|
||||
if result.RequeueAfter > 0 {
|
||||
return result, jenkins, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user