Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay committed Mar 5, 2024
1 parent ee96eac commit ff35070
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 10 additions & 14 deletions apis/v1alpha1/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,15 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
Enabled: in.Enabled,
Affinity: in.Affinity,
PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
Enabled: in.PrometheusCR.Enabled,
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
PodMonitorSelector: toLabelSelector(in.PrometheusCR.PodMonitorSelector),
ServiceMonitorSelector: toLabelSelector(in.PrometheusCR.ServiceMonitorSelector),
Enabled: in.PrometheusCR.Enabled,
ScrapeInterval: in.PrometheusCR.ScrapeInterval,
// prometheus_cr.pod_monitor_selector shouldn't be nil when selector is empty
PodMonitorSelector: &metav1.LabelSelector{
MatchLabels: in.PrometheusCR.PodMonitorSelector,
},
ServiceMonitorSelector: &metav1.LabelSelector{
MatchLabels: in.PrometheusCR.ServiceMonitorSelector,
},
},
SecurityContext: in.SecurityContext,
PodSecurityContext: in.PodSecurityContext,
Expand All @@ -176,15 +181,6 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
}
}

func toLabelSelector(selector map[string]string) *metav1.LabelSelector {
if selector == nil {
return nil
}
return &metav1.LabelSelector{
MatchLabels: selector,
}
}

func tov1beta1Autoscaler(in *AutoscalerSpec, minReplicas, maxReplicas *int32) *v1beta1.AutoscalerSpec {
if in == nil {
return nil
Expand Down Expand Up @@ -279,7 +275,7 @@ func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, err
SecurityContext: copy.Spec.SecurityContext,
PodSecurityContext: copy.Spec.PodSecurityContext,
PodAnnotations: copy.Spec.PodAnnotations,
TargetAllocator: tov1alpha1TA(in.Spec.TargetAllocator),
TargetAllocator: tov1alpha1TA(copy.Spec.TargetAllocator),
Mode: Mode(copy.Spec.Mode),
ServiceAccount: copy.Spec.ServiceAccount,
Image: copy.Spec.Image,
Expand Down
6 changes: 6 additions & 0 deletions apis/v1alpha1/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ func TestConvertTo(t *testing.T) {
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
ServiceAccount: "otelcol",
},
TargetAllocator: v1beta1.TargetAllocatorEmbedded{
PrometheusCR: v1beta1.TargetAllocatorPrometheusCR{
PodMonitorSelector: &metav1.LabelSelector{},
ServiceMonitorSelector: &metav1.LabelSelector{},
},
},
},
Status: v1beta1.OpenTelemetryCollectorStatus{
Image: "otel/col",
Expand Down

0 comments on commit ff35070

Please sign in to comment.