Skip to content

Commit 3af6929

Browse files
committed
scaffold: update code examples to be valid
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
1 parent 863e785 commit 3af6929

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

designs/simplified-scaffolding.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ In this new layout, `main.go` constructs the reconciler:
203203
// ...
204204
func main() {
205205
// ...
206-
err := &controllers.MyReconciler{
206+
err := (&controllers.MyReconciler{
207207
MySuperSpecialAppClient: doSomeThingsWithFlags(),
208-
}.SetupWithManager(mgr)
208+
}).SetupWithManager(mgr)
209209
// ...
210210
}
211211
```
@@ -214,7 +214,7 @@ while `mykind_controller.go` actually sets up the controller using the
214214
reconciler:
215215

216216
```go
217-
func (r *myReconciler) SetupWithManager(mgr ctrl.Manager) error {
217+
func (r *MyReconciler) SetupWithManager(mgr ctrl.Manager) error {
218218
return ctrl.NewControllerManagedBy(mgr).
219219
For(&api.MyAppType{}).
220220
Owns(&corev1.Pod{}).
@@ -425,10 +425,10 @@ func main() {
425425
os.Exit(1)
426426
}
427427

428-
err = controllers.MyKindReconciler{
428+
err = (&controllers.MyKindReconciler{
429429
Client: mgr.GetClient(),
430430
log: ctrl.Log.WithName("mykind-controller"),
431-
}.SetupWithManager(mgr)
431+
}).SetupWithManager(mgr)
432432
if err != nil {
433433
setupLog.Error(err, "unable to create controller", "controller", "mykind")
434434
os.Exit(1)
@@ -463,12 +463,12 @@ import (
463463
"my.repo/api/v1"
464464
)
465465

466-
type myKindReconciler struct {
466+
type MyKindReconciler struct {
467467
client.Client
468468
log logr.Logger
469469
}
470470

471-
func (r *myKindReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
471+
func (r *MyKindReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
472472
ctx := context.Background()
473473
log := r.log.WithValues("mykind", req.NamespacedName)
474474

@@ -477,7 +477,7 @@ func (r *myKindReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
477477
return req.Result{}, nil
478478
}
479479

480-
func (r *myKindReconciler) SetupWithManager(mgr ctrl.Manager) error {
480+
func (r *MyKindReconciler) SetupWithManager(mgr ctrl.Manager) error {
481481
return ctrl.NewControllerManagedBy(mgr).
482482
For(v1.MyKind{}).
483483
Complete(r)

0 commit comments

Comments
 (0)