Skip to content

Commit d06fdcf

Browse files
committed
fix: remove service from function args
1 parent 873ac0b commit d06fdcf

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

pkg/service/model_build_listener.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ func (t *defaultModelBuildTask) buildListeners(ctx context.Context, scheme elbv2
2020
}
2121

2222
for _, port := range t.service.Spec.Ports {
23-
_, err := t.buildListener(ctx, t.service, port, *cfg, scheme)
23+
_, err := t.buildListener(ctx, port, *cfg, scheme)
2424
if err != nil {
2525
return err
2626
}
2727
}
2828
return nil
2929
}
3030

31-
func (t *defaultModelBuildTask) buildListener(ctx context.Context, svc *corev1.Service, port corev1.ServicePort, cfg listenerConfig,
31+
func (t *defaultModelBuildTask) buildListener(ctx context.Context, port corev1.ServicePort, cfg listenerConfig,
3232
scheme elbv2model.LoadBalancerScheme) (*elbv2model.Listener, error) {
33-
lsSpec, err := t.buildListenerSpec(ctx, svc, port, cfg, scheme)
33+
lsSpec, err := t.buildListenerSpec(ctx, port, cfg, scheme)
3434
if err != nil {
3535
return nil, err
3636
}
@@ -39,7 +39,7 @@ func (t *defaultModelBuildTask) buildListener(ctx context.Context, svc *corev1.S
3939
return ls, nil
4040
}
4141

42-
func (t *defaultModelBuildTask) buildListenerSpec(ctx context.Context, svc *corev1.Service, port corev1.ServicePort, cfg listenerConfig,
42+
func (t *defaultModelBuildTask) buildListenerSpec(ctx context.Context, port corev1.ServicePort, cfg listenerConfig,
4343
scheme elbv2model.LoadBalancerScheme) (elbv2model.ListenerSpec, error) {
4444
tgProtocol := elbv2model.Protocol(port.Protocol)
4545
listenerProtocol := elbv2model.Protocol(port.Protocol)
@@ -55,7 +55,7 @@ func (t *defaultModelBuildTask) buildListenerSpec(ctx context.Context, svc *core
5555
if err != nil {
5656
return elbv2model.ListenerSpec{}, err
5757
}
58-
targetGroup, err := t.buildTargetGroup(ctx, svc, port, tgProtocol, scheme)
58+
targetGroup, err := t.buildTargetGroup(ctx, port, tgProtocol, scheme)
5959
if err != nil {
6060
return elbv2model.ListenerSpec{}, err
6161
}

pkg/service/model_build_target_group.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const (
3030
healthCheckPortTrafficPort = "traffic-port"
3131
)
3232

33-
func (t *defaultModelBuildTask) buildTargetGroup(ctx context.Context, svc *corev1.Service, port corev1.ServicePort, tgProtocol elbv2model.Protocol, scheme elbv2model.LoadBalancerScheme) (*elbv2model.TargetGroup, error) {
33+
func (t *defaultModelBuildTask) buildTargetGroup(ctx context.Context, port corev1.ServicePort, tgProtocol elbv2model.Protocol, scheme elbv2model.LoadBalancerScheme) (*elbv2model.TargetGroup, error) {
3434
svcPort := intstr.FromInt(int(port.Port))
3535
tgResourceID := t.buildTargetGroupResourceID(k8s.NamespacedName(t.service), svcPort)
3636
if targetGroup, exists := t.tgByResID[tgResourceID]; exists {
@@ -40,7 +40,7 @@ func (t *defaultModelBuildTask) buildTargetGroup(ctx context.Context, svc *corev
4040
if err != nil {
4141
return nil, err
4242
}
43-
healthCheckConfig, err := t.buildTargetGroupHealthCheckConfig(ctx, svc, targetType)
43+
healthCheckConfig, err := t.buildTargetGroupHealthCheckConfig(ctx, targetType)
4444
if err != nil {
4545
return nil, err
4646
}
@@ -89,22 +89,22 @@ func (t *defaultModelBuildTask) buildTargetGroupSpec(ctx context.Context, tgProt
8989
}, nil
9090
}
9191

92-
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfig(ctx context.Context, svc *corev1.Service, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
92+
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfig(ctx context.Context, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
9393
if targetType == elbv2model.TargetTypeInstance && t.service.Spec.ExternalTrafficPolicy == corev1.ServiceExternalTrafficPolicyTypeLocal &&
9494
t.service.Spec.Type == corev1.ServiceTypeLoadBalancer {
95-
return t.buildTargetGroupHealthCheckConfigForInstanceModeLocal(ctx, svc, targetType)
95+
return t.buildTargetGroupHealthCheckConfigForInstanceModeLocal(ctx, targetType)
9696
}
97-
return t.buildTargetGroupHealthCheckConfigDefault(ctx, svc, targetType)
97+
return t.buildTargetGroupHealthCheckConfigDefault(ctx, targetType)
9898
}
9999

100-
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigDefault(ctx context.Context, svc *corev1.Service, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
100+
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigDefault(ctx context.Context, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
101101
healthCheckProtocol, err := t.buildTargetGroupHealthCheckProtocol(ctx, t.defaultHealthCheckProtocol)
102102
if err != nil {
103103
return nil, err
104104
}
105105
healthCheckPathPtr := t.buildTargetGroupHealthCheckPath(ctx, t.defaultHealthCheckPath, healthCheckProtocol)
106106
healthCheckMatcherPtr := t.buildTargetGroupHealthCheckMatcher(ctx, healthCheckProtocol)
107-
healthCheckPort, err := t.buildTargetGroupHealthCheckPort(ctx, svc, t.defaultHealthCheckPort, targetType)
107+
healthCheckPort, err := t.buildTargetGroupHealthCheckPort(ctx, t.defaultHealthCheckPort, targetType)
108108
if err != nil {
109109
return nil, err
110110
}
@@ -137,14 +137,14 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigDefault(ctx con
137137
}, nil
138138
}
139139

140-
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigForInstanceModeLocal(ctx context.Context, svc *corev1.Service, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
140+
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckConfigForInstanceModeLocal(ctx context.Context, targetType elbv2model.TargetType) (*elbv2model.TargetGroupHealthCheckConfig, error) {
141141
healthCheckProtocol, err := t.buildTargetGroupHealthCheckProtocol(ctx, t.defaultHealthCheckProtocolForInstanceModeLocal)
142142
if err != nil {
143143
return nil, err
144144
}
145145
healthCheckPathPtr := t.buildTargetGroupHealthCheckPath(ctx, t.defaultHealthCheckPathForInstanceModeLocal, healthCheckProtocol)
146146
healthCheckMatcherPtr := t.buildTargetGroupHealthCheckMatcher(ctx, healthCheckProtocol)
147-
healthCheckPort, err := t.buildTargetGroupHealthCheckPort(ctx, svc, t.defaultHealthCheckPortForInstanceModeLocal, targetType)
147+
healthCheckPort, err := t.buildTargetGroupHealthCheckPort(ctx, t.defaultHealthCheckPortForInstanceModeLocal, targetType)
148148
if err != nil {
149149
return nil, err
150150
}
@@ -276,7 +276,7 @@ func (t *defaultModelBuildTask) buildTargetGroupPort(_ context.Context, targetTy
276276
return 1
277277
}
278278

279-
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckPort(_ context.Context, svc *corev1.Service, defaultHealthCheckPort string, targetType elbv2model.TargetType) (intstr.IntOrString, error) {
279+
func (t *defaultModelBuildTask) buildTargetGroupHealthCheckPort(_ context.Context, defaultHealthCheckPort string, targetType elbv2model.TargetType) (intstr.IntOrString, error) {
280280
rawHealthCheckPort := defaultHealthCheckPort
281281
t.annotationParser.ParseStringAnnotation(annotations.SvcLBSuffixHCPort, &rawHealthCheckPort, t.service.Annotations)
282282
if rawHealthCheckPort == healthCheckPortTrafficPort {
@@ -287,7 +287,7 @@ func (t *defaultModelBuildTask) buildTargetGroupHealthCheckPort(_ context.Contex
287287
return healthCheckPort, nil
288288
}
289289

290-
svcPort, err := k8s.LookupServicePort(svc, healthCheckPort)
290+
svcPort, err := k8s.LookupServicePort(t.service, healthCheckPort)
291291
if err != nil {
292292
return intstr.IntOrString{}, errors.Wrap(err, "failed to resolve healthCheckPort")
293293
}

pkg/service/model_build_target_group_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func Test_defaultModelBuilderTask_buildTargetHealthCheck(t *testing.T) {
387387
defaultHealthCheckHealthyThresholdForInstanceModeLocal: 2,
388388
defaultHealthCheckUnhealthyThresholdForInstanceModeLocal: 2,
389389
}
390-
hc, err := builder.buildTargetGroupHealthCheckConfig(context.Background(), tt.svc, tt.targetType)
390+
hc, err := builder.buildTargetGroupHealthCheckConfig(context.Background(), tt.targetType)
391391
if tt.wantError {
392392
assert.Error(t, err)
393393
} else {
@@ -2013,7 +2013,7 @@ func Test_defaultModelBuilder_buildTargetGroupHealthCheckPort(t *testing.T) {
20132013
service: tt.svc,
20142014
defaultHealthCheckPort: tt.defaultPort,
20152015
}
2016-
got, err := builder.buildTargetGroupHealthCheckPort(context.Background(), tt.svc, tt.defaultPort, tt.targetType)
2016+
got, err := builder.buildTargetGroupHealthCheckPort(context.Background(), tt.defaultPort, tt.targetType)
20172017
if tt.wantErr != nil {
20182018
assert.EqualError(t, err, tt.wantErr.Error())
20192019
} else {

0 commit comments

Comments
 (0)