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 <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 0ee9f1b7a7
No known key found for this signature in database
GPG Key ID: 80D302F5886D839C
4 changed files with 11 additions and 11 deletions

View File

@ -437,7 +437,7 @@ func TestLifeCycleHook(t *testing.T) {
t.Run("consistent", func(t *testing.T) { t.Run("consistent", func(t *testing.T) {
ctx := context.Background() ctx := context.Background()
defer func() { fakeHTTP.req = nil }() 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 testPod.Spec.Containers[0].Lifecycle = httpLifeCycle
m.killContainer(ctx, testPod, cID, "foo", "testKill", "", &gracePeriod) m.killContainer(ctx, testPod, cID, "foo", "testKill", "", &gracePeriod)

View File

@ -41,7 +41,7 @@ func TestContainerLabels(t *testing.T) {
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Path: "path", Path: "path",
Host: "host", Host: "host",
Port: intstr.FromInt(8080), Port: intstr.FromInt32(8080),
Scheme: "scheme", Scheme: "scheme",
}, },
TCPSocket: &v1.TCPSocketAction{ TCPSocket: &v1.TCPSocketAction{
@ -110,7 +110,7 @@ func TestContainerAnnotations(t *testing.T) {
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Path: "path", Path: "path",
Host: "host", Host: "host",
Port: intstr.FromInt(8080), Port: intstr.FromInt32(8080),
Scheme: "scheme", Scheme: "scheme",
}, },
TCPSocket: &v1.TCPSocketAction{ TCPSocket: &v1.TCPSocketAction{

View File

@ -179,7 +179,7 @@ func TestRunHandlerHttp(t *testing.T) {
PostStart: &v1.LifecycleHandler{ PostStart: &v1.LifecycleHandler{
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Host: "foo", Host: "foo",
Port: intstr.FromInt(8080), Port: intstr.FromInt32(8080),
Path: "bar", Path: "bar",
}, },
}, },
@ -216,7 +216,7 @@ func TestRunHandlerHttpWithHeaders(t *testing.T) {
PostStart: &v1.LifecycleHandler{ PostStart: &v1.LifecycleHandler{
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Host: "foo", Host: "foo",
Port: intstr.FromInt(8080), Port: intstr.FromInt32(8080),
Path: "/bar", Path: "/bar",
HTTPHeaders: []v1.HTTPHeader{ HTTPHeaders: []v1.HTTPHeader{
{Name: "Foo", Value: "bar"}, {Name: "Foo", Value: "bar"},
@ -739,7 +739,7 @@ func TestRunHandlerHttpFailure(t *testing.T) {
PostStart: &v1.LifecycleHandler{ PostStart: &v1.LifecycleHandler{
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Host: "foo", Host: "foo",
Port: intstr.FromInt(8080), Port: intstr.FromInt32(8080),
Path: "bar", Path: "bar",
}, },
}, },

View File

@ -44,14 +44,14 @@ func TestGetURLParts(t *testing.T) {
port int port int
path string 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(""), Path: ""}, false, "", -1, ""},
{&v1.HTTPGetAction{Host: "", Port: intstr.FromString("-1"), 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("not-found"), Path: ""}, false, "", -1, ""},
{&v1.HTTPGetAction{Host: "", Port: intstr.FromString("found"), Path: ""}, true, "127.0.0.1", 93, ""}, {&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: "", 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 { for _, test := range testCases {
@ -98,12 +98,12 @@ func TestGetTCPAddrParts(t *testing.T) {
host string host string
port int 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("")}, false, "", -1},
{&v1.TCPSocketAction{Port: intstr.FromString("-1")}, false, "", -1}, {&v1.TCPSocketAction{Port: intstr.FromString("-1")}, false, "", -1},
{&v1.TCPSocketAction{Port: intstr.FromString("not-found")}, 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.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}, {&v1.TCPSocketAction{Port: intstr.FromString("118")}, true, "1.2.3.4", 118},
} }