Replace a function closure

Replace more closures with pointer conversion

Replace deprecated Int32Ptr to Int32
This commit is contained in:
Yuan Chen
2023-02-22 18:45:16 -08:00
parent 53b8170b97
commit a24aef6510
13 changed files with 66 additions and 65 deletions

View File

@@ -832,7 +832,7 @@ func testDeploymentCleanUpPolicy(ctx context.Context, f *framework.Framework) {
}
rsName := "test-cleanup-controller"
replicas := int32(1)
revisionHistoryLimit := utilpointer.Int32Ptr(0)
revisionHistoryLimit := utilpointer.Int32(0)
_, err := c.AppsV1().ReplicaSets(ns).Create(ctx, newRS(rsName, replicas, rsPodLabels, WebserverImageName, WebserverImage, nil), metav1.CreateOptions{})
framework.ExpectNoError(err)

View File

@@ -46,6 +46,7 @@ import (
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/format"
"k8s.io/utils/pointer"
)
var _ = SIGDescribe("ReplicationController", func() {
@@ -458,7 +459,7 @@ func newRC(rsName string, replicas int32, rcPodLabels map[string]string, imageNa
Name: rsName,
},
Spec: v1.ReplicationControllerSpec{
Replicas: func(i int32) *int32 { return &i }(replicas),
Replicas: pointer.Int32(replicas),
Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: rcPodLabels,

View File

@@ -54,6 +54,7 @@ import (
e2estatefulset "k8s.io/kubernetes/test/e2e/framework/statefulset"
imageutils "k8s.io/kubernetes/test/utils/image"
admissionapi "k8s.io/pod-security-admission/api"
"k8s.io/utils/pointer"
)
const (
@@ -322,10 +323,8 @@ var _ = SIGDescribe("StatefulSet", func() {
Type: appsv1.RollingUpdateStatefulSetStrategyType,
RollingUpdate: func() *appsv1.RollingUpdateStatefulSetStrategy {
return &appsv1.RollingUpdateStatefulSetStrategy{
Partition: func() *int32 {
i := int32(3)
return &i
}()}
Partition: pointer.Int32(3),
}
}(),
}
ss, err := c.AppsV1().StatefulSets(ns).Create(ctx, ss, metav1.CreateOptions{})
@@ -377,10 +376,8 @@ var _ = SIGDescribe("StatefulSet", func() {
Type: appsv1.RollingUpdateStatefulSetStrategyType,
RollingUpdate: func() *appsv1.RollingUpdateStatefulSetStrategy {
return &appsv1.RollingUpdateStatefulSetStrategy{
Partition: func() *int32 {
i := int32(2)
return &i
}()}
Partition: pointer.Int32(2),
}
}(),
}
ss, err = updateStatefulSetWithRetries(ctx, c, ns, ss.Name, func(update *appsv1.StatefulSet) {
@@ -388,10 +385,8 @@ var _ = SIGDescribe("StatefulSet", func() {
Type: appsv1.RollingUpdateStatefulSetStrategyType,
RollingUpdate: func() *appsv1.RollingUpdateStatefulSetStrategy {
return &appsv1.RollingUpdateStatefulSetStrategy{
Partition: func() *int32 {
i := int32(2)
return &i
}()}
Partition: pointer.Int32(2),
}
}(),
}
})