Skip to content

Commit

Permalink
Simplify event recording example
Browse files Browse the repository at this point in the history
There is no need for `fmt.Sprintf` since `EventRecorder` already has `Eventf` method that accepts formatting string
  • Loading branch information
rkosegi authored Sep 14, 2024
1 parent 0dcb3a2 commit 264499f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/book/src/reference/raising-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ Following is an example of a code implementation that raises an Event.

```go
// The following implementation will raise an event
r.Recorder.Event(cr, "Warning", "Deleting",
fmt.Sprintf("Custom Resource %s is being deleted from the namespace %s",
cr.Name,
cr.Namespace))
r.Recorder.Eventf(cr, "Warning", "Deleting",
"Custom Resource %s is being deleted from the namespace %s",
cr.Name, cr.Namespace)
```

</aside>
Expand Down Expand Up @@ -110,4 +109,4 @@ And then, run `$ make manifests` to update the rules under `config/rbac/role.yam
[Event-Example]: https://github.com/kubernetes/api/blob/6c11c9e4685cc62e4ddc8d4aaa824c46150c9148/core/v1/types.go#L6019-L6024
[Reason-Example]: https://github.com/kubernetes/api/blob/6c11c9e4685cc62e4ddc8d4aaa824c46150c9148/core/v1/types.go#L6048
[Message-Example]: https://github.com/kubernetes/api/blob/6c11c9e4685cc62e4ddc8d4aaa824c46150c9148/core/v1/types.go#L6053
[rbac-markers]: ./markers/rbac.md
[rbac-markers]: ./markers/rbac.md

0 comments on commit 264499f

Please sign in to comment.