Skip to content

Commit 264499f

Browse files
authored
Simplify event recording example
There is no need for `fmt.Sprintf` since `EventRecorder` already has `Eventf` method that accepts formatting string
1 parent 0dcb3a2 commit 264499f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/book/src/reference/raising-events.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ Following is an example of a code implementation that raises an Event.
3333

3434
```go
3535
// The following implementation will raise an event
36-
r.Recorder.Event(cr, "Warning", "Deleting",
37-
fmt.Sprintf("Custom Resource %s is being deleted from the namespace %s",
38-
cr.Name,
39-
cr.Namespace))
36+
r.Recorder.Eventf(cr, "Warning", "Deleting",
37+
"Custom Resource %s is being deleted from the namespace %s",
38+
cr.Name, cr.Namespace)
4039
```
4140

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

0 commit comments

Comments
 (0)