/
event.go
42 lines (33 loc) · 1.17 KB
/
event.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
// SPDX-License-Identifier: MIT
package event
import (
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
)
const (
CreatingEvent = "Creating"
UpdatingEvent = "Updating"
DeletingEvent = "Deleting"
ScalingEvent = "Scaling"
ErrorEvent = "Error"
InfoEvent = "Info"
)
func Creating(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeNormal, CreatingEvent, msg)
}
func Updating(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeNormal, UpdatingEvent, msg)
}
func Deleting(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeNormal, DeletingEvent, msg)
}
func Scaling(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeNormal, ScalingEvent, msg)
}
func Info(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeNormal, InfoEvent, msg)
}
func Error(recorder record.EventRecorder, obj client.Object, msg string) {
recorder.Event(obj, corev1.EventTypeWarning, ErrorEvent, msg)
}