Skip to content

Commit

Permalink
kubernetes/controller: simplify controller registration
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Feb 4, 2024
1 parent 4fc66f1 commit b907dd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ func (r *NodeReconciler) SetupWithManager(mgr ctrl.Manager) error {
r.Client = mgr.GetClient()
r.recorder = mgr.GetEventRecorderFor(controllerName)

// Register timed tasker
if err := mgr.Add(r); err != nil {
return err
}

return builder.
ControllerManagedBy(mgr).
For( // For is required, Owns and Watches are optional
Expand Down
7 changes: 1 addition & 6 deletions kubernetes/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ func run(config *rest.Config) error {
return err
}

nodeReconciler := &controllerruntime.NodeReconciler{}
if err = nodeReconciler.SetupWithManager(mgr); err != nil {
return err
}
// Register timed tasker
if err = mgr.Add(nodeReconciler); err != nil {
if err = (&controllerruntime.NodeReconciler{}).SetupWithManager(mgr); err != nil {
return err
}

Expand Down

0 comments on commit b907dd5

Please sign in to comment.