@@ -31,7 +31,6 @@ type ServiceBackendConfig struct {
3131 Service * corev1.Service
3232 ELBV2TargetGroupProps * elbv2gw.TargetGroupProps
3333 ServicePort * corev1.ServicePort
34- TypeSpecificBackend interface {}
3534}
3635
3736type LiteralTargetGroupConfig struct {
@@ -51,11 +50,11 @@ type attachedRuleAccumulator[RuleType any] interface {
5150}
5251
5352type attachedRuleAccumulatorImpl [RuleType any ] struct {
54- backendLoader func (ctx context.Context , k8sClient client.Client , typeSpecificBackend interface {}, backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error )
53+ backendLoader func (ctx context.Context , k8sClient client.Client , backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error )
5554 listenerRuleConfigLoader func (ctx context.Context , k8sClient client.Client , routeIdentifier types.NamespacedName , routeKind RouteKind , listenerRuleConfigRefs []gwv1.LocalObjectReference ) (* elbv2gw.ListenerRuleConfiguration , error , error )
5655}
5756
58- func newAttachedRuleAccumulator [RuleType any ](backendLoader func (ctx context.Context , k8sClient client.Client , typeSpecificBackend interface {}, backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error ),
57+ func newAttachedRuleAccumulator [RuleType any ](backendLoader func (ctx context.Context , k8sClient client.Client , backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error ),
5958 listenerRuleConfigLoader func (ctx context.Context , k8sClient client.Client , routeIdentifier types.NamespacedName , routeKind RouteKind , listenerRuleConfigRefs []gwv1.LocalObjectReference ) (* elbv2gw.ListenerRuleConfiguration , error , error )) attachedRuleAccumulator [RuleType ] {
6059 return & attachedRuleAccumulatorImpl [RuleType ]{
6160 backendLoader : backendLoader ,
@@ -85,7 +84,7 @@ func (ara *attachedRuleAccumulatorImpl[RuleType]) accumulateRules(ctx context.Co
8584 // If ListenerRuleConfig is loaded properly without any warning errors, then only load backends, else it should be treated as no valid backend to send with fixed 503 response
8685 if lrcWarningErr == nil {
8786 for _ , backend := range backendRefIterator (rule ) {
88- convertedBackend , warningErr , fatalErr := ara .backendLoader (ctx , k8sClient , backend , backend , route .GetRouteNamespacedName (), route .GetRouteKind ())
87+ convertedBackend , warningErr , fatalErr := ara .backendLoader (ctx , k8sClient , backend , route .GetRouteNamespacedName (), route .GetRouteKind ())
8988 if warningErr != nil {
9089 allErrors = append (allErrors , routeLoadError {
9190 Err : warningErr ,
@@ -114,16 +113,16 @@ func (ara *attachedRuleAccumulatorImpl[RuleType]) accumulateRules(ctx context.Co
114113// warning error -> continue with reconcile cycle.
115114// fatal error -> stop reconcile cycle (probably k8s api outage)
116115// commonBackendLoader this function will load the services and target group configurations associated with this gateway backend.
117- func commonBackendLoader (ctx context.Context , k8sClient client.Client , typeSpecificBackend interface {}, backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error ) {
116+ func commonBackendLoader (ctx context.Context , k8sClient client.Client , backendRef gwv1.BackendRef , routeIdentifier types.NamespacedName , routeKind RouteKind ) (* Backend , error , error ) {
118117
119118 var serviceBackend * ServiceBackendConfig
120119 var literalTargetGroup * LiteralTargetGroupConfig
121120 var warn error
122121 var fatal error
123122 // We only support references of type service.
124123 if backendRef .Kind == nil || * backendRef .Kind == "Service" {
125- serviceBackend , warn , fatal = serviceLoader (ctx , k8sClient , typeSpecificBackend , routeIdentifier , routeKind , backendRef )
126- } else if string (* backendRef .Kind ) == TargetGroupARNBackend {
124+ serviceBackend , warn , fatal = serviceLoader (ctx , k8sClient , routeIdentifier , routeKind , backendRef )
125+ } else if string (* backendRef .Kind ) == TargetGroupNameBackend {
127126 literalTargetGroup , warn , fatal = literalTargetGroupLoader (backendRef )
128127 }
129128
@@ -157,12 +156,13 @@ func commonBackendLoader(ctx context.Context, k8sClient client.Client, typeSpeci
157156 return nil , nil , errors .Errorf ("Weight [%d] must be less than or equal to %d" , weight , maxWeight )
158157 }
159158 return & Backend {
160- ServiceBackend : serviceBackend ,
161- Weight : weight ,
159+ ServiceBackend : serviceBackend ,
160+ LiteralTargetGroup : literalTargetGroup ,
161+ Weight : weight ,
162162 }, nil , nil
163163}
164164
165- func serviceLoader (ctx context.Context , k8sClient client.Client , typeSpecificBackend interface {}, routeIdentifier types.NamespacedName , routeKind RouteKind , backendRef gwv1.BackendRef ) (* ServiceBackendConfig , error , error ) {
165+ func serviceLoader (ctx context.Context , k8sClient client.Client , routeIdentifier types.NamespacedName , routeKind RouteKind , backendRef gwv1.BackendRef ) (* ServiceBackendConfig , error , error ) {
166166 if backendRef .Port == nil {
167167 initialErrorMessage := "Port is required"
168168 wrappedGatewayErrorMessage := generateInvalidMessageWithRouteDetails (initialErrorMessage , routeKind , routeIdentifier )
@@ -273,7 +273,6 @@ func serviceLoader(ctx context.Context, k8sClient client.Client, typeSpecificBac
273273 return & ServiceBackendConfig {
274274 Service : svc ,
275275 ServicePort : servicePort ,
276- TypeSpecificBackend : typeSpecificBackend ,
277276 ELBV2TargetGroupProps : tgProps ,
278277 }, nil , nil
279278}
0 commit comments