Skip to content

Commit f648508

Browse files
committed
Link to documentation from README.md
1 parent 2f99031 commit f648508

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
The Kubernetes controller-runtime Project is a set of go libraries for building Controllers.
77

8+
Documentation:
9+
10+
- Package overview [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg)
11+
- Basic controller using builder [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/builder#example-Builder)
12+
- Creating a manager [link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/manager#example-New)
13+
- Creating a controller[link](https://godoc.org/github.com/kubernetes-sigs/controller-runtime/pkg/controller#example-New)
14+
15+
Example: [main](https://github.com/kubernetes-sigs/controller-runtime/blob/master/example/main.go)
816

917
## Community, discussion, contribution, and support
1018

pkg/controller/example_test.go

+9-16
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,12 @@ func ExampleNew() {
4444
}
4545
}
4646

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.
4948
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
6150

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.
6453
c, err := controller.New("pod-controller", mrg, controller.Options{
6554
Reconciler: reconcile.Func(func(o reconcile.Request) (reconcile.Result, error) {
6655
// Your business logic to implement the API by creating, updating, deleting objects goes here.
@@ -71,11 +60,15 @@ func ExampleController_Watch() {
7160
log.Fatal(err)
7261
}
7362

63+
// Watch for Pod create / update / delete events and call Reconcile
7464
err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{})
7565
if err != nil {
7666
log.Fatal(err)
7767
}
68+
if err != nil {
69+
log.Fatal(err)
70+
}
7871

72+
// Start the Controller through the manager.
7973
mrg.Start(signals.SetupSignalHandler())
80-
8174
}

pkg/manager/example_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ var mrg manager.Manager
2828

2929
// This example creates a new Manager that can be used with controller.New to create Controllers.
3030
func ExampleNew() {
31-
mrg, err := manager.New(config.GetConfigOrDie(), manager.Options{})
31+
cfg, err := config.GetConfig()
32+
if err != nil {
33+
log.Fatal(err)
34+
}
35+
36+
mrg, err := manager.New(cfg, manager.Options{})
3237
if err != nil {
3338
log.Fatal(err)
3439
}

0 commit comments

Comments
 (0)