mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-27 15:39:39 +00:00
Allow inclusion of annotations in channel events when using FakeRecorder
Kubernetes-commit: 9839ce96f557413f522230fa3e374e26356ae3d9
This commit is contained in:
parent
dda9c5244f
commit
a43f324cb9
@ -29,6 +29,7 @@ type FakeRecorder struct {
|
||||
Events chan string
|
||||
|
||||
IncludeObject bool
|
||||
IncludeAnnotations bool
|
||||
}
|
||||
|
||||
func objectString(object runtime.Object, includeObject bool) string {
|
||||
@ -54,8 +55,13 @@ func (f *FakeRecorder) Eventf(object runtime.Object, eventtype, reason, messageF
|
||||
}
|
||||
|
||||
func (f *FakeRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{}) {
|
||||
if f.IncludeAnnotations {
|
||||
args = append(args, fmt.Sprint(annotations))
|
||||
f.Eventf(object, eventtype, reason, messageFmt+" %s", args...)
|
||||
} else {
|
||||
f.Eventf(object, eventtype, reason, messageFmt, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// NewFakeRecorder creates new fake event recorder with event channel with
|
||||
// buffer of given size.
|
||||
|
Loading…
Reference in New Issue
Block a user