Skip to content

Commit d9e4328

Browse files
committed
remove unused parameter
1 parent 9653ed9 commit d9e4328

File tree

8 files changed

+18
-20
lines changed

8 files changed

+18
-20
lines changed

pkg/gateway/routeutils/backend.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type ServiceBackendConfig struct {
3131
Service *corev1.Service
3232
ELBV2TargetGroupProps *elbv2gw.TargetGroupProps
3333
ServicePort *corev1.ServicePort
34-
TypeSpecificBackend interface{}
3534
}
3635

3736
type LiteralTargetGroupConfig struct {
@@ -51,11 +50,11 @@ type attachedRuleAccumulator[RuleType any] interface {
5150
}
5251

5352
type 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
}

pkg/gateway/routeutils/backend_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"testing"
1717
)
1818

19-
func TestCommonBackendLoader(t *testing.T) {
19+
func TestCommonBackendLoader_Service(t *testing.T) {
2020

2121
kind := HTTPRouteKind
2222

@@ -372,7 +372,7 @@ func TestCommonBackendLoader(t *testing.T) {
372372
assert.NoError(t, err, fmt.Sprintf("%+v", g))
373373
}
374374

375-
result, warningErr, fatalErr := commonBackendLoader(context.Background(), k8sClient, tc.backendRef, tc.backendRef, tc.routeIdentifier, kind)
375+
result, warningErr, fatalErr := commonBackendLoader(context.Background(), k8sClient, tc.backendRef, tc.routeIdentifier, kind)
376376

377377
if tc.expectWarning {
378378
assert.Error(t, warningErr)
@@ -393,7 +393,6 @@ func TestCommonBackendLoader(t *testing.T) {
393393
assert.Equal(t, tc.storedService, result.ServiceBackend.Service)
394394
assert.Equal(t, tc.weight, result.Weight)
395395
assert.Equal(t, tc.servicePort, result.ServiceBackend.ServicePort.Port)
396-
assert.Equal(t, tc.backendRef, result.ServiceBackend.TypeSpecificBackend)
397396

398397
if tc.expectedTargetGroup == nil {
399398
assert.Nil(t, result.ServiceBackend.ELBV2TargetGroupProps)

pkg/gateway/routeutils/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
)
2020

2121
const (
22-
TargetGroupARNBackend string = "TargetGroupARN"
22+
TargetGroupNameBackend string = "TargetGroupName"
2323
)
2424

2525
// RouteKind to Route Loader. These functions will pull data directly from the kube api or local cache.

pkg/gateway/routeutils/grpc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func Test_ListGRPCRoutes(t *testing.T) {
129129

130130
func Test_GRPC_LoadAttachedRules(t *testing.T) {
131131
weight := 0
132-
mockBackendLoader := func(ctx context.Context, k8sClient client.Client, typeSpecificBackend interface{}, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
132+
mockBackendLoader := func(ctx context.Context, k8sClient client.Client, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
133133
weight++
134134
return &Backend{
135135
Weight: weight,

pkg/gateway/routeutils/http_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func Test_ListHTTPRoutes(t *testing.T) {
130130

131131
func Test_HTTP_LoadAttachedRules(t *testing.T) {
132132
weight := 0
133-
mockLoader := func(ctx context.Context, k8sClient client.Client, typeSpecificBackend interface{}, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
133+
mockLoader := func(ctx context.Context, k8sClient client.Client, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
134134
weight++
135135
return &Backend{
136136
Weight: weight,

pkg/gateway/routeutils/tcp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Test_ListTCPRoutes(t *testing.T) {
110110

111111
func Test_TCP_LoadAttachedRules(t *testing.T) {
112112
weight := 0
113-
mockLoader := func(ctx context.Context, k8sClient client.Client, typeSpecificBackend interface{}, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
113+
mockLoader := func(ctx context.Context, k8sClient client.Client, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
114114
weight++
115115
return &Backend{
116116
Weight: weight,

pkg/gateway/routeutils/tls_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func Test_ListTLSRoutes(t *testing.T) {
124124

125125
func Test_TLS_LoadAttachedRules(t *testing.T) {
126126
weight := 0
127-
mockLoader := func(ctx context.Context, k8sClient client.Client, typeSpecificBackend interface{}, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
127+
mockLoader := func(ctx context.Context, k8sClient client.Client, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
128128
weight++
129129
return &Backend{
130130
Weight: weight,

pkg/gateway/routeutils/udp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Test_ListUDPRoutes(t *testing.T) {
110110

111111
func Test_UDP_LoadAttachedRules(t *testing.T) {
112112
weight := 0
113-
mockLoader := func(ctx context.Context, k8sClient client.Client, typeSpecificBackend interface{}, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
113+
mockLoader := func(ctx context.Context, k8sClient client.Client, backendRef gwv1.BackendRef, routeIdentifier types.NamespacedName, routeKind RouteKind) (*Backend, error, error) {
114114
weight++
115115
return &Backend{
116116
Weight: weight,

0 commit comments

Comments
 (0)