mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
api-machinery: 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:
parent
f871d5fabe
commit
94410ee807
@ -50,14 +50,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service does not exist",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
expectCreate: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -106,14 +106,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition wrong port",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8000, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8000, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -125,7 +125,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -138,15 +138,15 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition missing port",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "baz", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
{Name: "baz", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -158,8 +158,8 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "baz", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
{Name: "baz", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -172,14 +172,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition incorrect port",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "bar", Port: 1000, Protocol: "UDP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "bar", Port: 1000, Protocol: "UDP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -191,7 +191,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -204,14 +204,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition incorrect port name",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 1000, Protocol: "UDP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "foo", Port: 1000, Protocol: "UDP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -223,7 +223,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -236,14 +236,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition incorrect target port",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -255,7 +255,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -268,14 +268,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition incorrect protocol",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "UDP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "UDP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -287,7 +287,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -300,14 +300,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition has incorrect type",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -319,7 +319,7 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -332,14 +332,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition satisfies",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
@ -391,14 +391,14 @@ func TestCreateOrUpdateMasterService(t *testing.T) {
|
||||
testName: "service definition wrong port, no expected update",
|
||||
serviceName: "foo",
|
||||
servicePorts: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt(8080)},
|
||||
{Name: "foo", Port: 8080, Protocol: "TCP", TargetPort: intstr.FromInt32(8080)},
|
||||
},
|
||||
serviceType: corev1.ServiceTypeClusterIP,
|
||||
service: &corev1.Service{
|
||||
ObjectMeta: om("foo"),
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: []corev1.ServicePort{
|
||||
{Name: "foo", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt(1000)},
|
||||
{Name: "foo", Port: 1000, Protocol: "TCP", TargetPort: intstr.FromInt32(1000)},
|
||||
},
|
||||
Selector: nil,
|
||||
ClusterIP: "1.2.3.4",
|
||||
|
@ -68,7 +68,7 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ClusterIP: "hit",
|
||||
Ports: []v1.ServicePort{
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -87,8 +87,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ClusterIP: "hit",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -107,8 +107,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ClusterIP: "hit",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -127,8 +127,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ClusterIP: "hit",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -152,8 +152,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
ClusterIP: "hit",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -196,8 +196,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
ClusterIP: "lb",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -216,8 +216,8 @@ func TestResolve(t *testing.T) {
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
ClusterIP: "np",
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt(1234)},
|
||||
{Name: "https", Port: 443, TargetPort: intstr.FromInt32(1443)},
|
||||
{Port: 1234, TargetPort: intstr.FromInt32(1234)},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1465,7 +1465,7 @@ func TestDoRequestNewWay(t *testing.T) {
|
||||
expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: intstr.FromInt(12345),
|
||||
TargetPort: intstr.FromInt32(12345),
|
||||
}}}}
|
||||
expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj)
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
@ -1708,7 +1708,7 @@ func TestDoRequestNewWayReader(t *testing.T) {
|
||||
expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: intstr.FromInt(12345),
|
||||
TargetPort: intstr.FromInt32(12345),
|
||||
}}}}
|
||||
expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj)
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
@ -1747,7 +1747,7 @@ func TestDoRequestNewWayObj(t *testing.T) {
|
||||
expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: intstr.FromInt(12345),
|
||||
TargetPort: intstr.FromInt32(12345),
|
||||
}}}}
|
||||
expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj)
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
@ -1802,7 +1802,7 @@ func TestDoRequestNewWayFile(t *testing.T) {
|
||||
expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: intstr.FromInt(12345),
|
||||
TargetPort: intstr.FromInt32(12345),
|
||||
}}}}
|
||||
expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj)
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
@ -1847,7 +1847,7 @@ func TestWasCreated(t *testing.T) {
|
||||
expectedObj := &v1.Service{Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{
|
||||
Protocol: "TCP",
|
||||
Port: 12345,
|
||||
TargetPort: intstr.FromInt(12345),
|
||||
TargetPort: intstr.FromInt32(12345),
|
||||
}}}}
|
||||
expectedBody, _ := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expectedObj)
|
||||
fakeHandler := utiltesting.FakeHandler{
|
||||
|
Loading…
Reference in New Issue
Block a user