test: 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
parent af1bf43067
commit 3418ceaca6
No known key found for this signature in database
GPG Key ID: 1CC5FA453662A71D
32 changed files with 93 additions and 93 deletions

View File

@ -251,7 +251,7 @@ func SetUpSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclien
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Scheme: v1.URISchemeHTTPS,
Port: intstr.FromInt(443),
Port: intstr.FromInt32(443),
Path: "/readyz",
},
},
@ -300,7 +300,7 @@ func SetUpSampleAPIServer(ctx context.Context, f *framework.Framework, aggrclien
{
Protocol: v1.ProtocolTCP,
Port: aggregatorServicePort,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},

View File

@ -291,7 +291,7 @@ func deployCustomResourceWebhookAndService(ctx context.Context, f *framework.Fra
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Scheme: v1.URISchemeHTTPS,
Port: intstr.FromInt(int(containerPort)),
Port: intstr.FromInt32(containerPort),
Path: "/readyz",
},
},
@ -333,7 +333,7 @@ func deployCustomResourceWebhookAndService(ctx context.Context, f *framework.Fra
{
Protocol: v1.ProtocolTCP,
Port: servicePort,
TargetPort: intstr.FromInt(int(containerPort)),
TargetPort: intstr.FromInt32(containerPort),
},
},
},

View File

@ -56,7 +56,7 @@ func testingPod(name, value string) v1.Pod {
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/index.html",
Port: intstr.FromInt(8080),
Port: intstr.FromInt32(8080),
},
},
InitialDelaySeconds: 30,

View File

@ -170,7 +170,7 @@ func ensureServicesAreRemovedWhenNamespaceIsDeleted(ctx context.Context, f *fram
Selector: labels,
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -2058,7 +2058,7 @@ func newTestServiceForQuota(name string, serviceType v1.ServiceType, allocateLoa
Type: serviceType,
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
AllocateLoadBalancerNodePorts: allocateNPs,
},

View File

@ -790,7 +790,7 @@ func deployWebhookAndService(ctx context.Context, f *framework.Framework, image
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Scheme: v1.URISchemeHTTPS,
Port: intstr.FromInt(int(containerPort)),
Port: intstr.FromInt32(containerPort),
Path: "/readyz",
},
},
@ -829,7 +829,7 @@ func deployWebhookAndService(ctx context.Context, f *framework.Framework, image
{
Protocol: v1.ProtocolTCP,
Port: servicePort,
TargetPort: intstr.FromInt(int(containerPort)),
TargetPort: intstr.FromInt32(containerPort),
},
},
},

View File

@ -510,7 +510,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
maxSurgeOverlap := 60 * time.Second
maxSurge := 1
surgePercent := intstr.FromString("20%")
zero := intstr.FromInt(0)
zero := intstr.FromInt32(0)
oldVersion := "1"
ds := newDaemonSet(dsName, image, label)
ds.Spec.Template.Spec.Containers[0].Env = []v1.EnvVar{

View File

@ -87,9 +87,9 @@ var _ = SIGDescribe("DisruptionController", func() {
framework.ConformanceIt("should list and delete a collection of PodDisruptionBudgets", func(ctx context.Context) {
specialLabels := map[string]string{"foo_pdb": "bar_pdb"}
labelSelector := labels.SelectorFromSet(specialLabels).String()
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt(2), specialLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt32(2), specialLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, "foo2", intstr.FromString("1%"), specialLabels)
createPDBMinAvailableOrDie(ctx, anotherFramework.ClientSet, anotherFramework.Namespace.Name, "foo3", intstr.FromInt(2), specialLabels)
createPDBMinAvailableOrDie(ctx, anotherFramework.ClientSet, anotherFramework.Namespace.Name, "foo3", intstr.FromInt32(2), specialLabels)
ginkgo.By("listing a collection of PDBs across all namespaces")
listPDBs(ctx, cs, metav1.NamespaceAll, labelSelector, 3, []string{defaultName, "foo2", "foo3"})
@ -139,7 +139,7 @@ var _ = SIGDescribe("DisruptionController", func() {
how many disruptions are allowed.
*/
framework.ConformanceIt("should observe PodDisruptionBudget status updated", func(ctx context.Context) {
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt(1), defaultLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt32(1), defaultLabels)
createPodsOrDie(ctx, cs, ns, 3)
waitForPodsOrDie(ctx, cs, ns, 3)
@ -162,7 +162,7 @@ var _ = SIGDescribe("DisruptionController", func() {
Description: PodDisruptionBudget API must support update and patch operations on status subresource.
*/
framework.ConformanceIt("should update/patch PodDisruptionBudget status", func(ctx context.Context) {
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt(1), defaultLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt32(1), defaultLabels)
ginkgo.By("Updating PodDisruptionBudget status")
// PDB status can be updated by both PDB controller and the status API. The test selects `DisruptedPods` field to show immediate update via API.
@ -194,7 +194,7 @@ var _ = SIGDescribe("DisruptionController", func() {
// PDB shouldn't error out when there are unmanaged pods
ginkgo.It("should observe that the PodDisruptionBudget status is not updated for unmanaged pods",
func(ctx context.Context) {
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt(1), defaultLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt32(1), defaultLabels)
createPodsOrDie(ctx, cs, ns, 3)
waitForPodsOrDie(ctx, cs, ns, 3)
@ -228,13 +228,13 @@ var _ = SIGDescribe("DisruptionController", func() {
shouldDeny: false,
}, {
description: "too few pods, absolute",
minAvailable: intstr.FromInt(2),
minAvailable: intstr.FromInt32(2),
maxUnavailable: intstr.FromString(""),
podCount: 2,
shouldDeny: true,
}, {
description: "enough pods, absolute",
minAvailable: intstr.FromInt(2),
minAvailable: intstr.FromInt32(2),
maxUnavailable: intstr.FromString(""),
podCount: 3,
shouldDeny: false,
@ -266,7 +266,7 @@ var _ = SIGDescribe("DisruptionController", func() {
{
description: "maxUnavailable deny evictions, integer",
minAvailable: intstr.FromString(""),
maxUnavailable: intstr.FromInt(1),
maxUnavailable: intstr.FromInt32(1),
replicaSetSize: 10,
exclusive: true,
shouldDeny: true,
@ -348,7 +348,7 @@ var _ = SIGDescribe("DisruptionController", func() {
*/
framework.ConformanceIt("should block an eviction until the PDB is updated to allow it", func(ctx context.Context) {
ginkgo.By("Creating a pdb that targets all three pods in a test replica set")
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt(3), defaultLabels)
createPDBMinAvailableOrDie(ctx, cs, ns, defaultName, intstr.FromInt32(3), defaultLabels)
createReplicaSetOrDie(ctx, cs, ns, 3, false)
ginkgo.By("First trying to evict a pod which shouldn't be evictable")
@ -370,7 +370,7 @@ var _ = SIGDescribe("DisruptionController", func() {
ginkgo.By("Updating the pdb to allow a pod to be evicted")
updatePDBOrDie(ctx, cs, ns, defaultName, func(pdb *policyv1.PodDisruptionBudget) *policyv1.PodDisruptionBudget {
newMinAvailable := intstr.FromInt(2)
newMinAvailable := intstr.FromInt32(2)
pdb.Spec.MinAvailable = &newMinAvailable
return pdb
}, cs.PolicyV1().PodDisruptionBudgets(ns).Update)
@ -386,7 +386,7 @@ var _ = SIGDescribe("DisruptionController", func() {
oldData, err := json.Marshal(old)
framework.ExpectNoError(err, "failed to marshal JSON for old data")
old.Spec.MinAvailable = nil
maxUnavailable := intstr.FromInt(0)
maxUnavailable := intstr.FromInt32(0)
old.Spec.MaxUnavailable = &maxUnavailable
newData, err := json.Marshal(old)
framework.ExpectNoError(err, "failed to marshal JSON for new data")

View File

@ -470,7 +470,7 @@ var _ = SIGDescribe("Probing container", func() {
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(8080),
Port: intstr.FromInt32(8080),
},
},
InitialDelaySeconds: 10,
@ -936,7 +936,7 @@ func (b webserverProbeBuilder) build() *v1.Probe {
probe.InitialDelaySeconds = probeTestInitialDelaySeconds
}
if b.failing {
probe.HTTPGet.Port = intstr.FromInt(81)
probe.HTTPGet.Port = intstr.FromInt32(81)
}
return probe
}

View File

@ -171,7 +171,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() {
HTTPGet: &v1.HTTPGetAction{
Path: "/echo?msg=poststart",
Host: targetIP,
Port: intstr.FromInt(8080),
Port: intstr.FromInt32(8080),
},
},
}
@ -194,7 +194,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() {
Scheme: v1.URISchemeHTTPS,
Path: "/echo?msg=poststart",
Host: targetIP,
Port: intstr.FromInt(9090),
Port: intstr.FromInt32(9090),
},
},
}
@ -216,7 +216,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() {
HTTPGet: &v1.HTTPGetAction{
Path: "/echo?msg=prestop",
Host: targetIP,
Port: intstr.FromInt(8080),
Port: intstr.FromInt32(8080),
},
},
}
@ -239,7 +239,7 @@ var _ = SIGDescribe("Container Lifecycle Hook", func() {
Scheme: v1.URISchemeHTTPS,
Path: "/echo?msg=prestop",
Host: targetIP,
Port: intstr.FromInt(9090),
Port: intstr.FromInt32(9090),
},
},
}

View File

@ -481,7 +481,7 @@ var _ = SIGDescribe("Pods", func() {
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{
Port: 8765,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
}},
Selector: map[string]string{
"name": serverName,

View File

@ -663,7 +663,7 @@ func (j *TestJig) newRCTemplate() *v1.ReplicationController {
PeriodSeconds: 3,
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Port: intstr.FromInt(80),
Port: intstr.FromInt32(80),
Path: "/hostName",
},
},
@ -716,7 +716,7 @@ func (j *TestJig) CreatePDB(ctx context.Context, rc *v1.ReplicationController) (
// this j, but does not actually create the PDB. The default PDB specifies a
// MinAvailable of N-1 and matches the pods created by the RC.
func (j *TestJig) newPDBTemplate(rc *v1.ReplicationController) *policyv1.PodDisruptionBudget {
minAvailable := intstr.FromInt(int(*rc.Spec.Replicas) - 1)
minAvailable := intstr.FromInt32(*rc.Spec.Replicas - 1)
pdb := &policyv1.PodDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{

View File

@ -137,7 +137,7 @@ var _ = common.SIGDescribe("Conntrack", func() {
udpService, err := udpJig.CreateUDPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeNodePort
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)
@ -213,7 +213,7 @@ var _ = common.SIGDescribe("Conntrack", func() {
udpService, err := udpJig.CreateUDPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeClusterIP
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)
@ -300,7 +300,7 @@ var _ = common.SIGDescribe("Conntrack", func() {
udpService, err := udpJig.CreateUDPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeClusterIP
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)

View File

@ -268,7 +268,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
Ports: []v1.ServicePort{{
Name: "example",
Port: 80,
TargetPort: intstr.FromInt(3000),
TargetPort: intstr.FromInt32(3000),
Protocol: v1.ProtocolTCP,
}},
},
@ -300,7 +300,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
Ports: []v1.ServicePort{{
Name: "example-no-match",
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
Protocol: v1.ProtocolTCP,
}},
},

View File

@ -77,7 +77,7 @@ func (t *TestFixture) BuildServiceSpec() *v1.Service {
Selector: t.Labels,
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -106,7 +106,7 @@ var _ = common.SIGDescribe("CVE-2021-29923", func() {
svc.Spec.ClusterIP = clusterIPZero // IP with a leading zero
svc.Spec.Type = v1.ServiceTypeClusterIP
svc.Spec.Ports = []v1.ServicePort{
{Port: int32(servicePort), Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
{Port: int32(servicePort), Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(9376)},
}
})
framework.ExpectNoError(err)

View File

@ -1037,7 +1037,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
_, err = udpJig.CreateUDPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)
@ -1169,7 +1169,7 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
_, err = udpJig.CreateUDPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "udp", Protocol: v1.ProtocolUDP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)
@ -1425,7 +1425,7 @@ var _ = common.SIGDescribe("LoadBalancers ESIPP [Slow]", func() {
// Change service port to avoid collision with opened hostPorts
// in other tests that run in parallel.
if len(svc.Spec.Ports) != 0 {
svc.Spec.Ports[0].TargetPort = intstr.FromInt(int(svc.Spec.Ports[0].Port))
svc.Spec.Ports[0].TargetPort = intstr.FromInt32(svc.Spec.Ports[0].Port)
svc.Spec.Ports[0].Port = 8081
}

View File

@ -116,7 +116,7 @@ var _ = common.SIGDescribe("Proxy", func() {
{
Name: "portname2",
Port: 81,
TargetPort: intstr.FromInt(162),
TargetPort: intstr.FromInt32(162),
},
{
Name: "tlsportname1",
@ -126,7 +126,7 @@ var _ = common.SIGDescribe("Proxy", func() {
{
Name: "tlsportname2",
Port: 444,
TargetPort: intstr.FromInt(462),
TargetPort: intstr.FromInt32(462),
},
},
},
@ -166,7 +166,7 @@ var _ = common.SIGDescribe("Proxy", func() {
ReadinessProbe: &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Port: intstr.FromInt(80),
Port: intstr.FromInt32(80),
},
},
InitialDelaySeconds: 1,
@ -324,7 +324,7 @@ var _ = common.SIGDescribe("Proxy", func() {
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP,
}},
Selector: map[string]string{
@ -418,7 +418,7 @@ var _ = common.SIGDescribe("Proxy", func() {
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
Protocol: v1.ProtocolTCP,
}},
Selector: map[string]string{

View File

@ -437,7 +437,7 @@ func generateScaleTestServiceSpec(suffix string) *v1.Service {
Name: "http",
Protocol: v1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
}},
Selector: scaleTestLabels,
Type: v1.ServiceTypeNodePort,
@ -458,7 +458,7 @@ func generateScaleTestBackendDeploymentSpec(numReplicas int32) *appsv1.Deploymen
d.Spec.Template.Spec.Containers[0].ReadinessProbe = &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Port: intstr.FromInt(8080),
Port: intstr.FromInt32(8080),
Path: "/healthz",
},
},

View File

@ -108,7 +108,7 @@ var (
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{{
Port: int32(defaultServeHostnameServicePort),
TargetPort: intstr.FromInt(9376),
TargetPort: intstr.FromInt32(9376),
Protocol: v1.ProtocolTCP,
}},
Selector: map[string]string{
@ -1287,7 +1287,7 @@ var _ = common.SIGDescribe("Services", func() {
nodePortService, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeNodePort
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(9376)},
}
})
framework.ExpectNoError(err)
@ -1319,7 +1319,7 @@ var _ = common.SIGDescribe("Services", func() {
svc.Spec.Type = v1.ServiceTypeClusterIP
svc.Spec.ExternalIPs = []string{externalIP}
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(9376)},
}
})
if err != nil && strings.Contains(err.Error(), "Use of external IPs is denied by admission control") {
@ -1364,7 +1364,7 @@ var _ = common.SIGDescribe("Services", func() {
Name: "tcp-port",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(9376),
TargetPort: intstr.FromInt32(9376),
},
}
})
@ -1384,13 +1384,13 @@ var _ = common.SIGDescribe("Services", func() {
Name: "tcp-port",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(9376),
TargetPort: intstr.FromInt32(9376),
},
{
Name: "udp-port",
Port: 80,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(9376),
TargetPort: intstr.FromInt32(9376),
},
}
})
@ -1432,7 +1432,7 @@ var _ = common.SIGDescribe("Services", func() {
s.Spec.Type = v1.ServiceTypeClusterIP
s.Spec.ExternalName = ""
s.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(9376)},
}
})
framework.ExpectNoError(err)
@ -1471,7 +1471,7 @@ var _ = common.SIGDescribe("Services", func() {
s.Spec.Type = v1.ServiceTypeNodePort
s.Spec.ExternalName = ""
s.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(9376)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(9376)},
}
})
framework.ExpectNoError(err)
@ -1764,7 +1764,7 @@ var _ = common.SIGDescribe("Services", func() {
t.Name = "slow-terminating-unready-pod"
t.Image = imageutils.GetE2EImage(imageutils.Agnhost)
port := 80
port := int32(80)
terminateSeconds := int64(100)
service := &v1.Service{
@ -1776,8 +1776,8 @@ var _ = common.SIGDescribe("Services", func() {
Selector: t.Labels,
Ports: []v1.ServicePort{{
Name: "http",
Port: int32(port),
TargetPort: intstr.FromInt(port),
Port: port,
TargetPort: intstr.FromInt32(port),
}},
PublishNotReadyAddresses: true,
},
@ -1913,7 +1913,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.Type = v1.ServiceTypeNodePort
svc.Spec.PublishNotReadyAddresses = true
@ -2032,7 +2032,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.Type = v1.ServiceTypeNodePort
svc.Spec.PublishNotReadyAddresses = false
@ -2488,7 +2488,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.InternalTrafficPolicy = &local
})
@ -2556,7 +2556,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 8000, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(8000)},
{Port: 8000, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(8000)},
}
svc.Spec.InternalTrafficPolicy = &local
})
@ -2725,7 +2725,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyLocal
@ -2819,7 +2819,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
})
framework.ExpectNoError(err)
@ -2893,7 +2893,7 @@ var _ = common.SIGDescribe("Services", func() {
local := v1.ServiceInternalTrafficPolicyLocal
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.InternalTrafficPolicy = &local
})
@ -2970,7 +2970,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.Type = v1.ServiceTypeNodePort
})
@ -3045,7 +3045,7 @@ var _ = common.SIGDescribe("Services", func() {
jig := e2eservice.NewTestJig(cs, ns, serviceName)
svc, err := jig.CreateTCPService(ctx, func(svc *v1.Service) {
svc.Spec.Ports = []v1.ServicePort{
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt(80)},
{Port: 80, Name: "http", Protocol: v1.ProtocolTCP, TargetPort: intstr.FromInt32(80)},
}
svc.Spec.Type = v1.ServiceTypeNodePort
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyLocal
@ -3355,7 +3355,7 @@ var _ = common.SIGDescribe("Services", func() {
Name: "http",
Protocol: v1.ProtocolTCP,
Port: int32(80),
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -53,7 +53,7 @@ var _ = common.SIGDescribe("[Feature:Topology Hints]", func() {
})
ginkgo.It("should distribute endpoints evenly", func(ctx context.Context) {
portNum := 9376
portNum := int32(9376)
thLabels := map[string]string{labelKey: clientLabelValue}
img := imageutils.GetE2EImage(imageutils.Agnhost)
ports := []v1.ContainerPort{{ContainerPort: int32(portNum)}}
@ -74,7 +74,7 @@ var _ = common.SIGDescribe("[Feature:Topology Hints]", func() {
Ports: []v1.ServicePort{{
Name: "example",
Port: 80,
TargetPort: intstr.FromInt(portNum),
TargetPort: intstr.FromInt32(portNum),
Protocol: v1.ProtocolTCP,
}},
},

View File

@ -93,7 +93,7 @@ func SpreadServiceOrFail(ctx context.Context, f *framework.Framework, replicaCou
},
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -211,7 +211,7 @@ var _ = utils.SIGDescribe("EmptyDir wrapper volumes", func() {
func createGitServer(ctx context.Context, f *framework.Framework) (gitURL string, gitRepo string, cleanup func()) {
var err error
gitServerPodName := "git-server-" + string(uuid.NewUUID())
containerPort := 8000
containerPort := int32(8000)
labels := map[string]string{"name": gitServerPodName}
@ -232,7 +232,7 @@ func createGitServer(ctx context.Context, f *framework.Framework) (gitURL string
{
Name: "http-portal",
Port: int32(httpPort),
TargetPort: intstr.FromInt(containerPort),
TargetPort: intstr.FromInt32(containerPort),
},
},
},

View File

@ -196,7 +196,7 @@ func cleanupDaemonSets(t *testing.T, cs clientset.Interface, ds *apps.DaemonSet)
}
func newRollbackStrategy() *apps.DaemonSetUpdateStrategy {
one := intstr.FromInt(1)
one := intstr.FromInt32(1)
return &apps.DaemonSetUpdateStrategy{
Type: apps.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &apps.RollingUpdateDaemonSet{MaxUnavailable: &one},
@ -762,7 +762,7 @@ func TestLaunchWithHashCollision(t *testing.T) {
// Create new DaemonSet with RollingUpdate strategy
orgDs := newDaemonSet("foo", ns.Name)
oneIntString := intstr.FromInt(1)
oneIntString := intstr.FromInt32(1)
orgDs.Spec.UpdateStrategy = apps.DaemonSetUpdateStrategy{
Type: apps.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &apps.RollingUpdateDaemonSet{
@ -867,7 +867,7 @@ func TestDSCUpdatesPodLabelAfterDedupCurHistories(t *testing.T) {
// Create new DaemonSet with RollingUpdate strategy
orgDs := newDaemonSet("foo", ns.Name)
oneIntString := intstr.FromInt(1)
oneIntString := intstr.FromInt32(1)
orgDs.Spec.UpdateStrategy = apps.DaemonSetUpdateStrategy{
Type: apps.RollingUpdateDaemonSetStrategyType,
RollingUpdate: &apps.RollingUpdateDaemonSet{

View File

@ -251,7 +251,7 @@ func TestEmptySelector(t *testing.T) {
go pdbc.Run(ctx)
replicas := 4
minAvailable := intstr.FromInt(2)
minAvailable := intstr.FromInt32(2)
for j := 0; j < replicas; j++ {
createPod(ctx, t, fmt.Sprintf("pod-%d", j), nsName, map[string]string{"app": "test-crd"},
@ -366,7 +366,7 @@ func TestSelectorsForPodsWithoutLabels(t *testing.T) {
informers.Start(ctx.Done())
go pdbc.Run(ctx)
minAvailable := intstr.FromInt(1)
minAvailable := intstr.FromInt32(1)
// Create the PDB first and wait for it to settle.
pdbName := "test-pdb"

View File

@ -237,7 +237,7 @@ func TestCreateServiceSingleStackIPv4(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -722,7 +722,7 @@ func TestCreateServiceDualStackIPv4IPv6(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -953,7 +953,7 @@ func TestCreateServiceDualStackIPv6IPv4(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -1020,7 +1020,7 @@ func TestUpgradeDowngrade(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -1126,7 +1126,7 @@ func TestConvertToFromExternalName(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -1215,7 +1215,7 @@ func TestPreferDualStack(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@ -1288,7 +1288,7 @@ func TestServiceUpdate(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},

View File

@ -362,7 +362,7 @@ func TestEndpointWithTerminatingPod(t *testing.T) {
"foo": "bar",
},
Ports: []v1.ServicePort{
{Name: "port-443", Port: 443, Protocol: "TCP", TargetPort: intstr.FromInt(443)},
{Name: "port-443", Port: 443, Protocol: "TCP", TargetPort: intstr.FromInt32(443)},
},
},
}
@ -448,8 +448,8 @@ func newService(namespace, name string) *v1.Service {
Spec: v1.ServiceSpec{
Selector: labelMap(),
Ports: []v1.ServicePort{
{Name: "port-1338", Port: 1338, Protocol: "TCP", TargetPort: intstr.FromInt(1338)},
{Name: "port-1337", Port: 1337, Protocol: "TCP", TargetPort: intstr.FromInt(1337)},
{Name: "port-1338", Port: 1338, Protocol: "TCP", TargetPort: intstr.FromInt32(1338)},
{Name: "port-1337", Port: 1337, Protocol: "TCP", TargetPort: intstr.FromInt32(1337)},
},
},
}

View File

@ -158,7 +158,7 @@ func TestEndpointSliceTerminating(t *testing.T) {
"foo": "bar",
},
Ports: []corev1.ServicePort{
{Name: "port-443", Port: 443, Protocol: "TCP", TargetPort: intstr.FromInt(443)},
{Name: "port-443", Port: 443, Protocol: "TCP", TargetPort: intstr.FromInt32(443)},
},
},
}

View File

@ -79,7 +79,7 @@ func TestServicesFinalizersRepairLoop(t *testing.T) {
Ports: []v1.ServicePort{{
Port: 8443,
NodePort: 30443,
TargetPort: intstr.FromInt(8443),
TargetPort: intstr.FromInt32(8443),
Protocol: v1.ProtocolTCP,
}},
Type: v1.ServiceTypeNodePort,

View File

@ -591,7 +591,7 @@ func newService(name string, svcType v1.ServiceType, allocateNodePort bool) *v1.
AllocateLoadBalancerNodePorts: allocateNPs,
Ports: []v1.ServicePort{{
Port: int32(80),
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -673,7 +673,7 @@ func TestDefaultPodTopologySpreadScoring(t *testing.T) {
},
Ports: []v1.ServicePort{{
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
}},
},
}

View File

@ -155,7 +155,7 @@ func main() {
Ports: []v1.ServicePort{{
Protocol: "TCP",
Port: 9376,
TargetPort: intstr.FromInt(9376),
TargetPort: intstr.FromInt32(9376),
}},
Selector: map[string]string{
"name": "serve-hostname",