From 72d3ee8b6f2c9f56fd4d5db434c9b7fa5ff3036b Mon Sep 17 00:00:00 2001 From: MenD32 <92942774+MenD32@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:39:32 +0300 Subject: [PATCH] added nil checks Signed-off-by: MenD32 --- controllers/eventsource/resource.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/controllers/eventsource/resource.go b/controllers/eventsource/resource.go index ad94920a4c..22db038b28 100644 --- a/controllers/eventsource/resource.go +++ b/controllers/eventsource/resource.go @@ -398,8 +398,12 @@ func buildService(args *AdaptorArgs) (*corev1.Service, error) { Selector: args.Labels, }, } - svc.ObjectMeta.SetAnnotations(args.EventSource.Spec.Service.Metadata.Annotations) - svc.ObjectMeta.SetLabels(args.EventSource.Spec.Service.Metadata.Labels) + +if args.EventSource.Spec.Service.Metadata.Annotations != nil { + svc.ObjectMeta.SetAnnotations(args.EventSource.Spec.Service.Metadata.Annotations) +} +if args.EventSource.Spec.Service.Metadata.Labels != nil { svc.ObjectMeta.SetLabels(args.EventSource.Spec.Service.Metadata.Labels) +} if err := controllerscommon.SetObjectMeta(eventSource, svc, v1alpha1.SchemaGroupVersionKind); err != nil { return nil, err }