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 <skitt@redhat.com>
This commit is contained in:
Stephen Kitt 2023-03-14 16:17:48 +01:00 committed by Stephen Kitt
parent f871d5fabe
commit 1c4b97ea27
No known key found for this signature in database
GPG Key ID: 80D302F5886D839C
7 changed files with 64 additions and 64 deletions

View File

@ -355,7 +355,7 @@ func TestSyncEndpointsWithPodResourceVersionUpdateOnly(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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" pod0.ResourceVersion = "3"
@ -429,7 +429,7 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -569,7 +569,7 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -613,7 +613,7 @@ func TestSyncEndpointsProtocolSCTP(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -654,7 +654,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAll(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -694,7 +694,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllNotReady(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -734,7 +734,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllMixed(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -778,7 +778,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -821,7 +821,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: metav1.NamespaceDefault},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -841,8 +841,8 @@ func TestSyncEndpointsItems(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}, {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
{Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt(8088)}, {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt32(8088)},
}, },
}, },
}) })
@ -889,8 +889,8 @@ func TestSyncEndpointsItemsWithLabels(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt(8080)}, {Name: "port0", Port: 80, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
{Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt(8088)}, {Name: "port1", Port: 88, Protocol: "TCP", TargetPort: intstr.FromInt32(8088)},
}, },
}, },
}) })
@ -950,7 +950,7 @@ func TestSyncEndpointsItemsPreexistingLabelsChange(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -996,7 +996,7 @@ func TestWaitsForAllInformersToBeSynced2(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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) endpoints.serviceStore.Add(service)
@ -1097,7 +1097,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyNeverAndPhaseFail
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -1136,7 +1136,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyNeverAndPhaseSucc
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -1175,7 +1175,7 @@ func TestSyncEndpointsItemsExcludeNotReadyPodsWithRestartPolicyOnFailureAndPhase
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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") 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)}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns, CreationTimestamp: metav1.NewTime(triggerTime)},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") 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)}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns, CreationTimestamp: metav1.NewTime(triggerTime)},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")
@ -1547,7 +1547,7 @@ func TestLastTriggerChangeTimeAnnotation_AnnotationCleared(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{}, 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") endpoints.syncService(context.TODO(), ns+"/foo")

View File

@ -126,7 +126,7 @@ func TestSyncServiceNoSelector(t *testing.T) {
esController.serviceStore.Add(&v1.Service{ esController.serviceStore.Add(&v1.Service{
ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns},
Spec: v1.ServiceSpec{ 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}, ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns, DeletionTimestamp: &deletionTimestamp},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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{ esController.serviceStore.Add(&v1.Service{
ObjectMeta: metav1.ObjectMeta{Name: existingServiceName, Namespace: namespace}, ObjectMeta: metav1.ObjectMeta{Name: existingServiceName, Namespace: namespace},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}},
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
}, },
}) })
@ -504,9 +504,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
@ -621,9 +621,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv6Protocol}, IPFamilies: []v1.IPFamily{v1.IPv6Protocol},
@ -728,9 +728,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
@ -843,9 +843,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
@ -958,9 +958,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
@ -1090,9 +1090,9 @@ func TestSyncService(t *testing.T) {
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{Name: "tcp-example", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}, {Name: "tcp-example", TargetPort: intstr.FromInt32(80), Protocol: v1.ProtocolTCP},
{Name: "udp-example", TargetPort: intstr.FromInt(161), Protocol: v1.ProtocolUDP}, {Name: "udp-example", TargetPort: intstr.FromInt32(161), Protocol: v1.ProtocolUDP},
{Name: "sctp-example", TargetPort: intstr.FromInt(3456), Protocol: v1.ProtocolSCTP}, {Name: "sctp-example", TargetPort: intstr.FromInt32(3456), Protocol: v1.ProtocolSCTP},
}, },
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
@ -1664,7 +1664,7 @@ func TestSyncServiceStaleInformer(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns}, ObjectMeta: metav1.ObjectMeta{Name: serviceName, Namespace: ns},
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Selector: map[string]string{"foo": "bar"}, 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), UID: types.UID(namespace + "-" + serviceName),
}, },
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{TargetPort: intstr.FromInt(80)}}, Ports: []v1.ServicePort{{TargetPort: intstr.FromInt32(80)}},
Selector: map[string]string{"foo": "bar"}, Selector: map[string]string{"foo": "bar"},
IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
}, },

View File

@ -525,7 +525,7 @@ func TestGetEndpointPorts(t *testing.T) {
Ports: []v1.ServicePort{{ Ports: []v1.ServicePort{{
Name: "http", Name: "http",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: protoTCP, Protocol: protoTCP,
AppProtocol: pointer.String("example.com/custom-protocol"), AppProtocol: pointer.String("example.com/custom-protocol"),
}}, }},
@ -551,7 +551,7 @@ func TestGetEndpointPorts(t *testing.T) {
Ports: []v1.ServicePort{{ Ports: []v1.ServicePort{{
Name: "http", Name: "http",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: protoTCP, Protocol: protoTCP,
}, { }, {
Name: "https", Name: "https",

View File

@ -135,7 +135,7 @@ func TestServiceUpdatedNoPodChange(t *testing.T) {
// service's ports have changed. // service's ports have changed.
service.Spec = v1.ServiceSpec{ service.Spec = v1.ServiceSpec{
Selector: map[string]string{}, 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 // Currently we're not able to calculate trigger time for service updates, hence the returned

View File

@ -1763,7 +1763,7 @@ func TestOverallIPTablesRulesWithMultipleServices(t *testing.T) {
Name: "p80", Name: "p80",
Port: 80, Port: 80,
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
}} }}
}), }),
// create LoadBalancer service with Cluster traffic policy and source ranges // create LoadBalancer service with Cluster traffic policy and source ranges
@ -1793,7 +1793,7 @@ func TestOverallIPTablesRulesWithMultipleServices(t *testing.T) {
Name: "p80", Name: "p80",
Port: 80, Port: 80,
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
}} }}
}), }),
) )
@ -5138,7 +5138,7 @@ func TestEndpointSliceE2E(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
ClusterIP: "172.30.1.1", ClusterIP: "172.30.1.1",
Selector: map[string]string{"foo": "bar"}, 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{ Spec: v1.ServiceSpec{
ClusterIP: "172.30.1.1", ClusterIP: "172.30.1.1",
Selector: map[string]string{"foo": "bar"}, 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{ Ports: []v1.ServicePort{
{ {
Name: "", Name: "",
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Port: 80, Port: 80,
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
@ -6598,7 +6598,7 @@ func TestEndpointSliceWithTerminatingEndpointsTrafficPolicyCluster(t *testing.T)
Ports: []v1.ServicePort{ Ports: []v1.ServicePort{
{ {
Name: "", Name: "",
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Port: 80, Port: 80,
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },

View File

@ -4376,7 +4376,7 @@ func TestEndpointSliceE2E(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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", Type: "LoadBalancer",
HealthCheckNodePort: 30000, HealthCheckNodePort: 30000,
ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyLocal,
@ -4517,7 +4517,7 @@ func Test_HealthCheckNodePortWhenTerminating(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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 { if tc.internalTrafficPolicy != nil {
@ -4878,7 +4878,7 @@ func Test_EndpointSliceReadyAndTerminatingCluster(t *testing.T) {
{ {
Name: "", Name: "",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
}, },
@ -5055,7 +5055,7 @@ func Test_EndpointSliceReadyAndTerminatingLocal(t *testing.T) {
{ {
Name: "", Name: "",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
}, },
@ -5231,7 +5231,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingCluster(t *testing.T) {
{ {
Name: "", Name: "",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
}, },
@ -5407,7 +5407,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocal(t *testing.T) {
{ {
Name: "", Name: "",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
}, },
@ -5580,7 +5580,7 @@ func Test_EndpointSliceOnlyReadyAndTerminatingLocalWithFeatureGateDisabled(t *te
{ {
Name: "", Name: "",
Port: 80, Port: 80,
TargetPort: intstr.FromInt(80), TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP, Protocol: v1.ProtocolTCP,
}, },
}, },
@ -5915,7 +5915,7 @@ func TestNoEndpointsMetric(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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 { if tc.internalTrafficPolicy != nil {

View File

@ -895,7 +895,7 @@ func TestEndpointSlice(t *testing.T) {
Spec: v1.ServiceSpec{ Spec: v1.ServiceSpec{
ClusterIP: "172.20.1.1", ClusterIP: "172.20.1.1",
Selector: map[string]string{"foo": "bar"}, 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}},
}, },
}) })