Check EventRecorder is not nil

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2021-12-21 21:10:43 +00:00
parent 8d61ff76d3
commit facda8b422
No known key found for this signature in database
GPG Key ID: 9995233870E99BEE
1 changed files with 10 additions and 8 deletions

View File

@ -904,16 +904,18 @@ func (r *KustomizationReconciler) finalize(ctx context.Context, kustomization ku
func (r *KustomizationReconciler) event(ctx context.Context, kustomization kustomizev1.Kustomization, revision, severity, msg string, metadata map[string]string) {
log := logr.FromContext(ctx)
annotations := map[string]string{
kustomizev1.GroupVersion.Group + "/revision": revision,
}
if r.EventRecorder != nil {
annotations := map[string]string{
kustomizev1.GroupVersion.Group + "/revision": revision,
}
eventtype := "Normal"
if severity == events.EventSeverityError {
eventtype = "Warning"
}
eventtype := "Normal"
if severity == events.EventSeverityError {
eventtype = "Warning"
}
r.EventRecorder.AnnotatedEventf(&kustomization, annotations, eventtype, severity, msg)
r.EventRecorder.AnnotatedEventf(&kustomization, annotations, eventtype, severity, msg)
}
if r.ExternalEventRecorder != nil {
objRef, err := reference.GetReference(r.Scheme, &kustomization)