Check EventRecorder is not nil

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2021-12-21 14:03:32 +00:00
parent 93d7e43062
commit c9b1a4f4f8
No known key found for this signature in database
GPG Key ID: 9995233870E99BEE
1 changed files with 4 additions and 1 deletions

View File

@ -737,7 +737,10 @@ func (r *HelmReleaseReconciler) requestsForHelmChartChange(o client.Object) []re
// event emits a Kubernetes event and forwards the event to notification controller if configured.
func (r *HelmReleaseReconciler) event(ctx context.Context, hr v2.HelmRelease, revision, severity, msg string) {
r.EventRecorder.Event(&hr, "Normal", severity, msg)
if r.EventRecorder != nil {
r.EventRecorder.Event(&hr, "Normal", severity, msg)
}
objRef, err := reference.GetReference(r.Scheme, &hr)
if err != nil {
logr.FromContext(ctx).Error(err, "unable to send event")