From 1c4b97ea27224716dd2e3f9a315f6818e4a52223 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 14 Mar 2023 16:17:48 +0100 Subject: [PATCH] network: replace intstr.FromInt with intstr.FromInt32 This touches cases where FromInt() is used on numeric constants, or values which are already int32s, or int variables which are defined close by and can be changed to int32s with little impact. Signed-off-by: Stephen Kitt --- .../endpoint/endpoints_controller_test.go | 42 ++++++++--------- .../endpointslice_controller_test.go | 46 +++++++++---------- pkg/controller/endpointslice/utils_test.go | 4 +- .../endpoint/trigger_time_tracker_test.go | 2 +- pkg/proxy/iptables/proxier_test.go | 12 ++--- pkg/proxy/ipvs/proxier_test.go | 20 ++++---- pkg/proxy/winkernel/proxier_test.go | 2 +- 7 files changed, 64 insertions(+), 64 deletions(-) diff --git a/pkg/controller/endpoint/endpoints_controller_test.go b/pkg/controller/endpoint/endpoints_controller_test.go index 6f6a8a9eb36..8d16c7cddd0 100644 --- a/pkg/controller/endpoint/endpoints_controller_test.go +++ b/pkg/controller/endpoint/endpoints_controller_test.go @@ -355,7 +355,7 @@ func TestSyncEndpointsWithPodResourceVersionUpdateOnly(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) pod0.ResourceVersion = "3" @@ -429,7 +429,7 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -569,7 +569,7 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "UDP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "UDP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -613,7 +613,7 @@ func TestSyncEndpointsProtocolSCTP(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "SCTP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "SCTP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -654,7 +654,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAll(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -694,7 +694,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllNotReady(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -734,7 +734,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllMixed(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -778,7 +778,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -821,7 +821,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -841,8 +841,8 @@ func TestSyncEndpointsItems(t *testing.T) { Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, Ports: []v1.ServicePort{ - {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}, - {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt(8088)}, + {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}, + {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt32(8088)}, }, }, }) @@ -889,8 +889,8 @@ func TestSyncEndpointsItemsWithLabels(t *testing.T) { Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, Ports: []v1.ServicePort{ - {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}, - {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt(8088)}, + {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}, + {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt32(8088)}, }, }, }) @@ -950,7 +950,7 @@ func TestSyncEndpointsItemsPreexistingLabelsChange(t *testing.T) { }, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -996,7 +996,7 @@ func TestWaitsForAllInformersToBeSynced2(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, }, } endpoints.serviceStore.Add(service) @@ -1097,7 +1097,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyNeverAndPhaseFail ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -1136,7 +1136,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyNeverAndPhaseSucc ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -1175,7 +1175,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyOnFailureAndPhase ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}}, + Ports: []v1.ServicePort{{Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -1446,7 +1446,7 @@ func TestLastTriggerChangeTimeAnnotation(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns, CreationTimestamp: metav1.NewTime(triggerTime)}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -1496,7 +1496,7 @@ func TestLastTriggerChangeTimeAnnotation_AnnotationOverridden(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns, CreationTimestamp: metav1.NewTime(triggerTime)}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") @@ -1547,7 +1547,7 @@ func TestLastTriggerChangeTimeAnnotation_AnnotationCleared(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, }, }) endpoints.syncService(context.TODO(), ns+"/foo") diff --git a/pkg/controller/endpointslice/endpointslice_controller_test.go b/pkg/controller/endpointslice/endpointslice_controller_test.go index 5d6a98ef49d..90c0b8a035d 100644 --- a/pkg/controller/endpointslice/endpointslice_controller_test.go +++ b/pkg/controller/endpointslice/endpointslice_controller_test.go @@ -126,7 +126,7 @@ func TestSyncServiceNoSelector(t *testing.T) { esController.serviceStore.Add(&v1.Service{ ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns}, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, + Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}}, }, }) @@ -217,7 +217,7 @@ func TestSyncServicePendingDeletion(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns, DeletionTimestamp: &deletionTimestamp}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, + Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}}, }, }) @@ -259,7 +259,7 @@ func TestSyncServiceMissing(t *testing.T) { esController.serviceStore.Add(&v1.Service{ ObjectMeta: metav1.ObjectMeta{Name: existingServiceName, Namespace: namespace}, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, + Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}}, Selector: map[string]string{"foo": "bar"}, }, }) @@ -504,9 +504,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, @@ -621,9 +621,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv6Protocol}, @@ -728,9 +728,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, @@ -843,9 +843,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, @@ -958,9 +958,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, @@ -1090,9 +1090,9 @@ func TestSyncService(t *testing.T) { }, Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ - {Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, - {Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, - {Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, + {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}, + {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP}, + {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP}, }, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, @@ -1664,7 +1664,7 @@ func TestSyncServiceStaleInformer(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns}, Spec: v1.ServiceSpec{ Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, + Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}}, }, }) @@ -1979,7 +1979,7 @@ func createService(t *testing.T, esController *endpointSliceController, namespac UID: types.UID(namespace + "-" + serviceName), }, Spec: v1.ServiceSpec{ - Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, + Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}}, Selector: map[string]string{"foo": "bar"}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, }, diff --git a/pkg/controller/endpointslice/utils_test.go b/pkg/controller/endpointslice/utils_test.go index 265422141d9..378b3ff6bf4 100644 --- a/pkg/controller/endpointslice/utils_test.go +++ b/pkg/controller/endpointslice/utils_test.go @@ -525,7 +525,7 @@ func TestGetEndpointPorts(t *testing.T) { Ports: []v1.ServicePort{{ Name: "http", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: protoTCP, AppProtocol: pointer.String("example.com/custom-protocol"), }}, @@ -551,7 +551,7 @@ func TestGetEndpointPorts(t *testing.T) { Ports: []v1.ServicePort{{ Name: "http", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: protoTCP, }, { Name: "https", diff --git a/pkg/controller/util/endpoint/trigger_time_tracker_test.go b/pkg/controller/util/endpoint/trigger_time_tracker_test.go index 043664e2c05..c468147db3a 100644 --- a/pkg/controller/util/endpoint/trigger_time_tracker_test.go +++ b/pkg/controller/util/endpoint/trigger_time_tracker_test.go @@ -135,7 +135,7 @@ func TestServiceUpdatedNoPodChange(t *testing.T) { // service's ports have changed. service.Spec = v1.ServiceSpec{ Selector: map[string]string{}, - Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt(8080), Protocol: "TCP"}}, + Ports: []v1.ServicePort{{Port: 80, TargetPort: intstr.FromInt32(8080), Protocol: "TCP"}}, } // Currently we're not able to calculate trigger time for service updates, hence the returned diff --git a/pkg/proxy/iptables/proxier_test.go b/pkg/proxy/iptables/proxier_test.go index 374fb321330..0e5e7f8b0d9 100644 --- a/pkg/proxy/iptables/proxier_test.go +++ b/pkg/proxy/iptables/proxier_test.go @@ -1763,7 +1763,7 @@ func TestOverallIPTablesRulesWithMultipleServices(t *testing.T) { Name: "p80", Port: 80, Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), }} }), // create LoadBalancer service with Cluster traffic policy and source ranges @@ -1793,7 +1793,7 @@ func TestOverallIPTablesRulesWithMultipleServices(t *testing.T) { Name: "p80", Port: 80, Protocol: v1.ProtocolTCP, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), }} }), ) @@ -5138,7 +5138,7 @@ func TestEndpointSliceE2E(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.30.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, }) @@ -5198,7 +5198,7 @@ func TestHealthCheckNodePortWhenTerminating(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.30.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, }) @@ -5801,7 +5801,7 @@ func TestEndpointSliceWithTerminatingEndpointsTrafficPolicyLocal(t *testing.T) { Ports: []v1.ServicePort{ { Name: "", - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Port: 80, Protocol: v1.ProtocolTCP, }, @@ -6598,7 +6598,7 @@ func TestEndpointSliceWithTerminatingEndpointsTrafficPolicyCluster(t *testing.T) Ports: []v1.ServicePort{ { Name: "", - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Port: 80, Protocol: v1.ProtocolTCP, }, diff --git a/pkg/proxy/ipvs/proxier_test.go b/pkg/proxy/ipvs/proxier_test.go index 4a0e515cc9b..7899d7412da 100644 --- a/pkg/proxy/ipvs/proxier_test.go +++ b/pkg/proxy/ipvs/proxier_test.go @@ -4376,7 +4376,7 @@ func TestEndpointSliceE2E(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, }) @@ -4463,7 +4463,7 @@ func TestHealthCheckNodePortE2E(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, Type: "LoadBalancer", HealthCheckNodePort: 30000, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, @@ -4517,7 +4517,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, }) @@ -4768,7 +4768,7 @@ func TestTestInternalTrafficPolicyE2E(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, } if tc.internalTrafficPolicy != nil { @@ -4878,7 +4878,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) { { Name: "", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, }, }, @@ -5055,7 +5055,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) { { Name: "", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, }, }, @@ -5231,7 +5231,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) { { Name: "", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, }, }, @@ -5407,7 +5407,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) { { Name: "", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, }, }, @@ -5580,7 +5580,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocalWithFeatureGateDisabled(t *te { Name: "", Port: 80, - TargetPort: intstr.FromInt(80), + TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, }, }, @@ -5915,7 +5915,7 @@ func TestNoEndpointsMetric(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: "p80", Port: 80, TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP, NodePort: 30000}}, + Ports: []v1.ServicePort{{Name: "p80", Port: 80, TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP, NodePort: 30000}}, }, } if tc.internalTrafficPolicy != nil { diff --git a/pkg/proxy/winkernel/proxier_test.go b/pkg/proxy/winkernel/proxier_test.go index 555a9850747..c6b5e35d366 100644 --- a/pkg/proxy/winkernel/proxier_test.go +++ b/pkg/proxy/winkernel/proxier_test.go @@ -895,7 +895,7 @@ func TestEndpointSlice(t *testing.T) { Spec: v1.ServiceSpec{ ClusterIP: "172.20.1.1", Selector: map[string]string{"foo": "bar"}, - Ports: []v1.ServicePort{{Name: svcPortName.Port, TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}}, + Ports: []v1.ServicePort{{Name: svcPortName.Port, TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP}}, }, })