Skip to content

Commit

Permalink
Update creating-events.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajiyah-Salat committed May 17, 2023
1 parent 7804c3a commit b5720b9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/book/src/reference/creating-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Following is an example of a code implementation that raises an Event.
```

</aside>

## How to be able to raise Events?

Following are the steps with examples to help you raise events in your controller's reconciliations.
Expand Down Expand Up @@ -76,6 +77,21 @@ type MyKindReconciler struct {
}


### Passing the EventRecorder to the Controller
Events are published from a Controller using an [EventRecorder]`type CorrelatorOptions struct`,
which can be created for a Controller by calling `GetRecorder(name string)` on a Manager. See that we will change the implementation scaffolded in `cmd/main.go`:
```go
if err = (&controller.MyKindReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
// Note that we added the following line:
Recorder: mgr.GetEventRecorderFor("mykind-controller"),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "MyKind")
os.Exit(1)
}
```

### Passing the EventRecorder to the Controller
Events are published from a Controller using an [EventRecorder]`type CorrelatorOptions struct`,
which can be created for a Controller by calling `GetRecorder(name string)` on a Manager. See that we will change the implementation scaffolded in `cmd/main.go`:
Expand Down

0 comments on commit b5720b9

Please sign in to comment.