cleanup: Update deprecated FromInt to FromInt32 (#119858)

* redo commit

* apply suggestions from liggitt

* update Parse function based on suggestions

Kubernetes-commit: a5b3a4b738e9576b68c3083de8b72002e0b45551
This commit is contained in:
git-jxj 2023-08-17 00:33:01 +08:00 committed by Kubernetes Publisher
parent bc9397b64f
commit 826006cdb9
4 changed files with 7 additions and 7 deletions

4
go.mod
View File

@ -31,7 +31,7 @@ require (
golang.org/x/sys v0.10.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.0.0-20230810042731-2f6eec10c476
k8s.io/apimachinery v0.0.0-20230816074730-5f41d7c357e9
k8s.io/apimachinery v0.0.0-20230816163301-3e2600dc79fe
k8s.io/cli-runtime v0.0.0-20230807221238-0daafa128c61
k8s.io/client-go v0.0.0-20230816075647-9a5370b1eff6
k8s.io/component-base v0.0.0-20230816041302-b54afcf379c0
@ -96,7 +96,7 @@ require (
replace (
k8s.io/api => k8s.io/api v0.0.0-20230810042731-2f6eec10c476
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230816074730-5f41d7c357e9
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230816163301-3e2600dc79fe
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20230807221238-0daafa128c61
k8s.io/client-go => k8s.io/client-go v0.0.0-20230816075647-9a5370b1eff6
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20230815234323-164b07cd93ea

4
go.sum
View File

@ -275,8 +275,8 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20230810042731-2f6eec10c476 h1:1LpPoqkYurARQ/TQ0U3DRAclyCkM7hMCMCUVymCR3jM=
k8s.io/api v0.0.0-20230810042731-2f6eec10c476/go.mod h1:RFi7MZgMNqcWc0azfutkpPR/OdHWZjnTAwdFHTKjAUQ=
k8s.io/apimachinery v0.0.0-20230816074730-5f41d7c357e9 h1:4J8Fh9WB60vFT8lPEKhmg/S652Z3v6R+rEeeCp+72IA=
k8s.io/apimachinery v0.0.0-20230816074730-5f41d7c357e9/go.mod h1:X0xh/chESs2hP9koe+SdIAcXWcQ+RM5hy0ZynB+yEvw=
k8s.io/apimachinery v0.0.0-20230816163301-3e2600dc79fe h1:UjWeb1lUhxUf0Ryph1r1hz+pENt060neKZ+P3gKWrDc=
k8s.io/apimachinery v0.0.0-20230816163301-3e2600dc79fe/go.mod h1:X0xh/chESs2hP9koe+SdIAcXWcQ+RM5hy0ZynB+yEvw=
k8s.io/cli-runtime v0.0.0-20230807221238-0daafa128c61 h1:rucHwIDQTB+CBn5R+vYaAaLWUK+KKXPPPexdFng0PHY=
k8s.io/cli-runtime v0.0.0-20230807221238-0daafa128c61/go.mod h1:2TfvpatNccVWjkFyiHv65ekELznAVhjJ34PaFcSb/Vc=
k8s.io/client-go v0.0.0-20230816075647-9a5370b1eff6 h1:8MczL4KDXZ9JcYbob4ECVW7JqCy3axIAzGZ2yTyHgdI=

View File

@ -1709,13 +1709,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1-tcp",
Port: 53,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(53),
TargetPort: intstr.FromInt32(53),
},
{
Name: "port-1-udp",
Port: 53,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(53),
TargetPort: intstr.FromInt32(53),
},
},
ClusterIP: corev1.ClusterIPNone,

View File

@ -196,7 +196,7 @@ func generateService(genericParams map[string]interface{}) (runtime.Object, erro
if portNum, err := strconv.Atoi(targetPortString); err != nil {
targetPort = intstr.FromString(targetPortString)
} else {
targetPort = intstr.FromInt(portNum)
targetPort = intstr.FromInt32(int32(portNum))
}
// Use the same target-port for every port
for i := range service.Spec.Ports {