Skip to content

Commit

Permalink
Check EventRecorder is not nil
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
  • Loading branch information
Paulo Gomes committed Dec 21, 2021
1 parent 8d61ff7 commit 111f2f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 111f2f1

Please sign in to comment.