-
Notifications
You must be signed in to change notification settings - Fork 432
/
provider.go
49 lines (38 loc) · 1.08 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package kube
import (
"context"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/recorder"
"github.com/solo-io/go-utils/contextutils"
)
var _ recorder.Provider = new(noopProvider)
func NewNoopProvider() *noopProvider {
return &noopProvider{}
}
type noopProvider struct {
}
func (n *noopProvider) GetEventRecorderFor(name string) record.EventRecorder {
return &noopEventRecorder{}
}
type noopEventRecorder struct {
ctx context.Context
}
func (n *noopEventRecorder) Event(object runtime.Object, eventType, reason, message string) {
contextutils.LoggerFrom(n.ctx).Debugf("Event callback called")
}
func (n *noopEventRecorder) Eventf(
object runtime.Object,
eventType, reason, messageFmt string,
args ...interface{},
) {
contextutils.LoggerFrom(n.ctx).Debugf("Eventf callback called")
}
func (n *noopEventRecorder) AnnotatedEventf(
object runtime.Object,
annotations map[string]string,
eventType, reason, messageFmt string,
args ...interface{},
) {
contextutils.LoggerFrom(n.ctx).Debugf("AnnotatedEventf callback called")
}