@@ -44,23 +44,12 @@ func ExampleNew() {
44
44
}
45
45
}
46
46
47
- // This example creates a new Controller named "pod-controller" with a no-op reconcile function and registers
48
- // it with the DefaultControllerManager.
47
+ // This example starts a new Controller named "pod-controller" to Watch Pods and call a no-op Reconciler.
49
48
func ExampleController () {
50
- _ , err := controller .New ("pod-controller" , mrg , controller.Options {
51
- Reconciler : reconcile .Func (func (o reconcile.Request ) (reconcile.Result , error ) {
52
- // Your business logic to implement the API by creating, updating, deleting objects goes here.
53
- return reconcile.Result {}, nil
54
- }),
55
- })
56
- if err != nil {
57
- log .Fatal (err )
58
- }
59
- mrg .Start (signals .SetupSignalHandler ())
60
- }
49
+ // mrg is a manager.Manager
61
50
62
- // This example watches Pods and enqueues reconcile.Requests with the changed Pod Name and Namespace.
63
- func ExampleController_Watch () {
51
+ // Create a new Controller that will call the provided Reconciler function in response
52
+ // to events.
64
53
c , err := controller .New ("pod-controller" , mrg , controller.Options {
65
54
Reconciler : reconcile .Func (func (o reconcile.Request ) (reconcile.Result , error ) {
66
55
// Your business logic to implement the API by creating, updating, deleting objects goes here.
@@ -71,11 +60,15 @@ func ExampleController_Watch() {
71
60
log .Fatal (err )
72
61
}
73
62
63
+ // Watch for Pod create / update / delete events and call Reconcile
74
64
err = c .Watch (& source.Kind {Type : & v1.Pod {}}, & handler.EnqueueRequestForObject {})
75
65
if err != nil {
76
66
log .Fatal (err )
77
67
}
68
+ if err != nil {
69
+ log .Fatal (err )
70
+ }
78
71
72
+ // Start the Controller through the manager.
79
73
mrg .Start (signals .SetupSignalHandler ())
80
-
81
74
}
0 commit comments