Skip to content

Commit

Permalink
changed labels and annotations logic to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
MenD32 committed Sep 12, 2024
1 parent b5f535b commit 293fad2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions controllers/eventsource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ func buildService(args *AdaptorArgs) (*corev1.Service, error) {
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-eventsource-svc", eventSource.Name),
Namespace: eventSource.Namespace,
Labels: mergeLabels(args.EventSource.Labels, args.Labels),
},
Spec: corev1.ServiceSpec{
Ports: ports,
Expand All @@ -399,15 +398,21 @@ func buildService(args *AdaptorArgs) (*corev1.Service, error) {
},
}

labels := mergeLabels(args.EventSource.Labels, args.Labels)
annotations := make(map[string]string)

if args.EventSource.Spec.Service.Metadata != nil {
if args.EventSource.Spec.Service.Metadata.Labels != nil {
svc.ObjectMeta.SetLabels(args.EventSource.Spec.Service.Metadata.Labels)
labels = mergeLabels(labels, args.EventSource.Spec.Service.Metadata.Labels)
}
if args.EventSource.Spec.Service.Metadata.Annotations != nil {
svc.ObjectMeta.SetAnnotations(args.EventSource.Spec.Service.Metadata.Annotations)
annotations = mergeLabels(annotations, args.EventSource.Spec.Service.Metadata.Annotations)
}
}

svc.ObjectMeta.SetLabels(labels)
svc.ObjectMeta.SetAnnotations(annotations)

if err := controllerscommon.SetObjectMeta(eventSource, svc, v1alpha1.SchemaGroupVersionKind); err != nil {
return nil, err
}
Expand Down

0 comments on commit 293fad2

Please sign in to comment.