MCPcopy Index your code
hub / github.com/kubernetes-sigs/controller-runtime / ExampleNew

Function ExampleNew

pkg/controller/example_test.go:43–54  ·  view source on GitHub ↗

This example creates a new Controller named "pod-controller" with a no-op reconcile function. The manager.Manager will be used to Start the Controller, and will provide it a shared Cache and Client.

()

Source from the content-addressed store, hash-verified

41// This example creates a new Controller named "pod-controller" with a no-op reconcile function. The
42// manager.Manager will be used to Start the Controller, and will provide it a shared Cache and Client.
43func ExampleNew() {
44 _, err := controller.New("pod-controller", mgr, controller.Options{
45 Reconciler: reconcile.Func(func(context.Context, reconcile.Request) (reconcile.Result, error) {
46 // Your business logic to implement the API by creating, updating, deleting objects goes here.
47 return reconcile.Result{}, nil
48 }),
49 })
50 if err != nil {
51 log.Error(err, "unable to create pod-controller")
52 os.Exit(1)
53 }
54}
55
56// This example starts a new Controller named "pod-controller" to Watch Pods and call a no-op Reconciler.
57func ExampleController() {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…