-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.go
28 lines (22 loc) · 875 Bytes
/
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
// Package event contains functions for generating Kubernetes API events.
package event
import (
"context"
corev1 "k8s.io/api/core/v1"
"knative.dev/pkg/controller"
"github.com/zeiss/typhoon/pkg/apis/common/v1alpha1"
)
// Normal records a normal event for an API object.
func Normal(ctx context.Context, reason, msgFmt string, args ...interface{}) {
recordEvent(ctx, corev1.EventTypeNormal, reason, msgFmt, args...)
}
// Warn records a warning event for an API object.
func Warn(ctx context.Context, reason, msgFmt string, args ...interface{}) {
recordEvent(ctx, corev1.EventTypeWarning, reason, msgFmt, args...)
}
func recordEvent(ctx context.Context, typ, reason, msgFmt string, args ...interface{}) {
recorder := controller.GetEventRecorder(ctx)
if recorder != nil {
recorder.Eventf(v1alpha1.ReconcilableFromContext(ctx), typ, reason, msgFmt, args...)
}
}