From 0ee9f1b7a752327419937f1cda4cdf1fbd023286 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 14 Mar 2023 16:17:48 +0100 Subject: [PATCH] kubelet: 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 --- pkg/kubelet/kuberuntime/kuberuntime_container_test.go | 2 +- pkg/kubelet/kuberuntime/labels_test.go | 4 ++-- pkg/kubelet/lifecycle/handlers_test.go | 6 +++--- pkg/kubelet/prober/prober_test.go | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container_test.go b/pkg/kubelet/kuberuntime/kuberuntime_container_test.go index b0cda9911da..991cc86a494 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_container_test.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_container_test.go @@ -437,7 +437,7 @@ func TestLifeCycleHook(t *testing.T) { t.Run("consistent", func(t *testing.T) { ctx := context.Background() defer func() { fakeHTTP.req = nil }() - httpLifeCycle.PreStop.HTTPGet.Port = intstr.FromInt(80) + httpLifeCycle.PreStop.HTTPGet.Port = intstr.FromInt32(80) testPod.Spec.Containers[0].Lifecycle = httpLifeCycle m.killContainer(ctx, testPod, cID, "foo", "testKill", "", &gracePeriod) diff --git a/pkg/kubelet/kuberuntime/labels_test.go b/pkg/kubelet/kuberuntime/labels_test.go index 8ee21f30f99..b0b3b410bb7 100644 --- a/pkg/kubelet/kuberuntime/labels_test.go +++ b/pkg/kubelet/kuberuntime/labels_test.go @@ -41,7 +41,7 @@ func TestContainerLabels(t *testing.T) { HTTPGet: &v1.HTTPGetAction{ Path: "path", Host: "host", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), Scheme: "scheme", }, TCPSocket: &v1.TCPSocketAction{ @@ -110,7 +110,7 @@ func TestContainerAnnotations(t *testing.T) { HTTPGet: &v1.HTTPGetAction{ Path: "path", Host: "host", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), Scheme: "scheme", }, TCPSocket: &v1.TCPSocketAction{ diff --git a/pkg/kubelet/lifecycle/handlers_test.go b/pkg/kubelet/lifecycle/handlers_test.go index 962962dd95b..0e6bc0459be 100644 --- a/pkg/kubelet/lifecycle/handlers_test.go +++ b/pkg/kubelet/lifecycle/handlers_test.go @@ -179,7 +179,7 @@ func TestRunHandlerHttp(t *testing.T) { PostStart: &v1.LifecycleHandler{ HTTPGet: &v1.HTTPGetAction{ Host: "foo", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), Path: "bar", }, }, @@ -216,7 +216,7 @@ func TestRunHandlerHttpWithHeaders(t *testing.T) { PostStart: &v1.LifecycleHandler{ HTTPGet: &v1.HTTPGetAction{ Host: "foo", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), Path: "/bar", HTTPHeaders: []v1.HTTPHeader{ {Name: "Foo", Value: "bar"}, @@ -739,7 +739,7 @@ func TestRunHandlerHttpFailure(t *testing.T) { PostStart: &v1.LifecycleHandler{ HTTPGet: &v1.HTTPGetAction{ Host: "foo", - Port: intstr.FromInt(8080), + Port: intstr.FromInt32(8080), Path: "bar", }, }, diff --git a/pkg/kubelet/prober/prober_test.go b/pkg/kubelet/prober/prober_test.go index c9e1a316e57..58f7d5545cc 100644 --- a/pkg/kubelet/prober/prober_test.go +++ b/pkg/kubelet/prober/prober_test.go @@ -44,14 +44,14 @@ func TestGetURLParts(t *testing.T) { port int path string }{ - {&v1.HTTPGetAction{Host: "", Port: intstr.FromInt(-1), Path: ""}, false, "", -1, ""}, + {&v1.HTTPGetAction{Host: "", Port: intstr.FromInt32(-1), Path: ""}, false, "", -1, ""}, {&v1.HTTPGetAction{Host: "", Port: intstr.FromString(""), Path: ""}, false, "", -1, ""}, {&v1.HTTPGetAction{Host: "", Port: intstr.FromString("-1"), Path: ""}, false, "", -1, ""}, {&v1.HTTPGetAction{Host: "", Port: intstr.FromString("not-found"), Path: ""}, false, "", -1, ""}, {&v1.HTTPGetAction{Host: "", Port: intstr.FromString("found"), Path: ""}, true, "127.0.0.1", 93, ""}, - {&v1.HTTPGetAction{Host: "", Port: intstr.FromInt(76), Path: ""}, true, "127.0.0.1", 76, ""}, + {&v1.HTTPGetAction{Host: "", Port: intstr.FromInt32(76), Path: ""}, true, "127.0.0.1", 76, ""}, {&v1.HTTPGetAction{Host: "", Port: intstr.FromString("118"), Path: ""}, true, "127.0.0.1", 118, ""}, - {&v1.HTTPGetAction{Host: "hostname", Port: intstr.FromInt(76), Path: "path"}, true, "hostname", 76, "path"}, + {&v1.HTTPGetAction{Host: "hostname", Port: intstr.FromInt32(76), Path: "path"}, true, "hostname", 76, "path"}, } for _, test := range testCases { @@ -98,12 +98,12 @@ func TestGetTCPAddrParts(t *testing.T) { host string port int }{ - {&v1.TCPSocketAction{Port: intstr.FromInt(-1)}, false, "", -1}, + {&v1.TCPSocketAction{Port: intstr.FromInt32(-1)}, false, "", -1}, {&v1.TCPSocketAction{Port: intstr.FromString("")}, false, "", -1}, {&v1.TCPSocketAction{Port: intstr.FromString("-1")}, false, "", -1}, {&v1.TCPSocketAction{Port: intstr.FromString("not-found")}, false, "", -1}, {&v1.TCPSocketAction{Port: intstr.FromString("found")}, true, "1.2.3.4", 93}, - {&v1.TCPSocketAction{Port: intstr.FromInt(76)}, true, "1.2.3.4", 76}, + {&v1.TCPSocketAction{Port: intstr.FromInt32(76)}, true, "1.2.3.4", 76}, {&v1.TCPSocketAction{Port: intstr.FromString("118")}, true, "1.2.3.4", 118}, }