Skip to content

Commit 6377ed0

Browse files
authored
Explicitly convert TA allocation and filter strategy (open-telemetry#2893)
Signed-off-by: Pavol Loffay <[email protected]>
1 parent 4c86ce3 commit 6377ed0

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

apis/v1alpha1/convert.go

+43-4
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedde
170170
Replicas: in.Replicas,
171171
NodeSelector: in.NodeSelector,
172172
Resources: in.Resources,
173-
AllocationStrategy: v1beta1.TargetAllocatorAllocationStrategy(in.AllocationStrategy),
174-
FilterStrategy: v1beta1.TargetAllocatorFilterStrategy(in.FilterStrategy),
173+
AllocationStrategy: tov1beta1TAAllocationStrategy(in.AllocationStrategy),
174+
FilterStrategy: tov1beta1TAFilterStrategy(in.FilterStrategy),
175175
ServiceAccount: in.ServiceAccount,
176176
Image: in.Image,
177177
Enabled: in.Enabled,
@@ -440,8 +440,8 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat
440440
Replicas: in.Replicas,
441441
NodeSelector: in.NodeSelector,
442442
Resources: in.Resources,
443-
AllocationStrategy: OpenTelemetryTargetAllocatorAllocationStrategy(in.AllocationStrategy),
444-
FilterStrategy: string(in.FilterStrategy),
443+
AllocationStrategy: tov1alpha1TAAllocationStrategy(in.AllocationStrategy),
444+
FilterStrategy: tov1alpha1TAFilterStrategy(in.FilterStrategy),
445445
ServiceAccount: in.ServiceAccount,
446446
Image: in.Image,
447447
Enabled: in.Enabled,
@@ -466,3 +466,42 @@ func tov1alpha1TA(in v1beta1.TargetAllocatorEmbedded) OpenTelemetryTargetAllocat
466466
PodDisruptionBudget: tov1alpha1PodDisruptionBudget(in.PodDisruptionBudget),
467467
}
468468
}
469+
470+
func tov1alpha1TAFilterStrategy(strategy v1beta1.TargetAllocatorFilterStrategy) string {
471+
switch strategy {
472+
case v1beta1.TargetAllocatorFilterStrategyRelabelConfig:
473+
return string(strategy)
474+
}
475+
return ""
476+
}
477+
478+
func tov1alpha1TAAllocationStrategy(strategy v1beta1.TargetAllocatorAllocationStrategy) OpenTelemetryTargetAllocatorAllocationStrategy {
479+
switch strategy {
480+
case v1beta1.TargetAllocatorAllocationStrategyConsistentHashing:
481+
return OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing
482+
case v1beta1.TargetAllocatorAllocationStrategyPerNode:
483+
return OpenTelemetryTargetAllocatorAllocationStrategyPerNode
484+
case v1beta1.TargetAllocatorAllocationStrategyLeastWeighted:
485+
return OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted
486+
}
487+
return ""
488+
}
489+
490+
func tov1beta1TAFilterStrategy(strategy string) v1beta1.TargetAllocatorFilterStrategy {
491+
if strategy == string(v1beta1.TargetAllocatorFilterStrategyRelabelConfig) {
492+
return v1beta1.TargetAllocatorFilterStrategyRelabelConfig
493+
}
494+
return ""
495+
}
496+
497+
func tov1beta1TAAllocationStrategy(strategy OpenTelemetryTargetAllocatorAllocationStrategy) v1beta1.TargetAllocatorAllocationStrategy {
498+
switch strategy {
499+
case OpenTelemetryTargetAllocatorAllocationStrategyPerNode:
500+
return v1beta1.TargetAllocatorAllocationStrategyPerNode
501+
case OpenTelemetryTargetAllocatorAllocationStrategyConsistentHashing:
502+
return v1beta1.TargetAllocatorAllocationStrategyConsistentHashing
503+
case OpenTelemetryTargetAllocatorAllocationStrategyLeastWeighted:
504+
return v1beta1.TargetAllocatorAllocationStrategyLeastWeighted
505+
}
506+
return ""
507+
}

0 commit comments

Comments
 (0)