diff --git a/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go index 46dcb7903c7..758a4403a61 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go @@ -217,9 +217,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct continue } if scheduledTimeForJob != nil { - if mostRecentTime == nil { - mostRecentTime = scheduledTimeForJob - } else if mostRecentTime.Before(*scheduledTimeForJob) { + if mostRecentTime == nil || mostRecentTime.Before(*scheduledTimeForJob) { mostRecentTime = scheduledTimeForJob } } @@ -304,7 +302,7 @@ func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct if int32(i) >= int32(len(successfulJobs))-*cronJob.Spec.SuccessfulJobsHistoryLimit { break } - if err := r.Delete(ctx, job, client.PropagationPolicy(metav1.DeletePropagationBackground)); (err) != nil { + if err := r.Delete(ctx, job, client.PropagationPolicy(metav1.DeletePropagationBackground)); err != nil { log.Error(err, "unable to delete old successful job", "job", job) } else { log.V(0).Info("deleted old successful job", "job", job) diff --git a/hack/docs/internal/cronjob-tutorial/controller_implementation.go b/hack/docs/internal/cronjob-tutorial/controller_implementation.go index 6e844f96f7f..fed8c7c55b3 100644 --- a/hack/docs/internal/cronjob-tutorial/controller_implementation.go +++ b/hack/docs/internal/cronjob-tutorial/controller_implementation.go @@ -204,9 +204,7 @@ const ControllerReconcileLogic = `log := log.FromContext(ctx) continue } if scheduledTimeForJob != nil { - if mostRecentTime == nil { - mostRecentTime = scheduledTimeForJob - } else if mostRecentTime.Before(*scheduledTimeForJob) { + if mostRecentTime == nil || mostRecentTime.Before(*scheduledTimeForJob) { mostRecentTime = scheduledTimeForJob } } @@ -291,7 +289,7 @@ const ControllerReconcileLogic = `log := log.FromContext(ctx) if int32(i) >= int32(len(successfulJobs))-*cronJob.Spec.SuccessfulJobsHistoryLimit { break } - if err := r.Delete(ctx, job, client.PropagationPolicy(metav1.DeletePropagationBackground)); (err) != nil { + if err := r.Delete(ctx, job, client.PropagationPolicy(metav1.DeletePropagationBackground)); err != nil { log.Error(err, "unable to delete old successful job", "job", job) } else { log.V(0).Info("deleted old successful job", "job", job) diff --git a/pkg/plugin/util/testdata/exampleFile.txt b/pkg/plugin/util/testdata/exampleFile.txt index c0ddde7d310..5e35d24aa18 100644 --- a/pkg/plugin/util/testdata/exampleFile.txt +++ b/pkg/plugin/util/testdata/exampleFile.txt @@ -1 +1 @@ -exampleTargetexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCode \ No newline at end of file +exampleTargetexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCodeexampleCode \ No newline at end of file