Skip to content

Commit 3b1ccc2

Browse files
authored
Fix nil pointer in Finalizer example
1 parent 3bfc84e commit 3b1ccc2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/book/src/cronjob-tutorial/testdata/finalizer_example.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The code snippet below shows skeleton code for implementing a finalizer.
4949
func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
5050
log := r.Log.WithValues("cronjob", req.NamespacedName)
5151

52-
var cronJob *batchv1.CronJob
52+
cronJob := &batchv1.CronJob{}
5353
if err := r.Get(ctx, req.NamespacedName, cronJob); err != nil {
5454
log.Error(err, "unable to fetch CronJob")
5555
// we'll ignore not-found errors, since they can't be fixed by an immediate

0 commit comments

Comments
 (0)