Merge pull request #110902 from 0xff-dev/master

convert int32 to pointer using library function
This commit is contained in:
Kubernetes Prow Robot 2022-10-14 08:48:46 -07:00 committed by GitHub
commit 5c36a3c372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 9 deletions

View File

@ -52,6 +52,7 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/securitycontext"
testingclock "k8s.io/utils/clock/testing"
"k8s.io/utils/pointer"
"github.com/stretchr/testify/assert"
)
@ -76,7 +77,7 @@ func newReplicationController(replicas int) *v1.ReplicationController {
ResourceVersion: "18",
},
Spec: v1.ReplicationControllerSpec{
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Selector: map[string]string{"foo": "bar"},
Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
@ -138,7 +139,7 @@ func newReplicaSet(name string, replicas int) *apps.ReplicaSet {
ResourceVersion: "18",
},
Spec: apps.ReplicaSetSpec{
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{

View File

@ -47,6 +47,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/controller/testutil"
"k8s.io/utils/pointer"
)
var (
@ -62,7 +63,7 @@ func rs(name string, replicas int, selector map[string]string, timestamp metav1.
Namespace: metav1.NamespaceDefault,
},
Spec: apps.ReplicaSetSpec{
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Selector: &metav1.LabelSelector{MatchLabels: selector},
Template: v1.PodTemplateSpec{},
},
@ -94,7 +95,7 @@ func newDeployment(name string, replicas int, revisionHistoryLimit *int32, maxSu
MaxSurge: func() *intstr.IntOrString { i := intstr.FromInt(0); return &i }(),
},
},
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Selector: &metav1.LabelSelector{MatchLabels: selector},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
@ -132,7 +133,7 @@ func newReplicaSet(d *apps.Deployment, name string, replicas int) *apps.ReplicaS
},
Spec: apps.ReplicaSetSpec{
Selector: d.Spec.Selector,
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Template: d.Spec.Template,
},
}

View File

@ -41,6 +41,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/utils/pointer"
)
func TestRealHistory_ListControllerRevisions(t *testing.T) {
@ -1649,7 +1650,7 @@ func newStatefulSet(replicas int, name string, uid types.UID, labels map[string]
MatchLabels: nil,
MatchExpressions: testMatchExpressions,
},
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,

View File

@ -53,6 +53,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
. "k8s.io/kubernetes/pkg/controller/testutil"
"k8s.io/kubernetes/pkg/securitycontext"
"k8s.io/utils/pointer"
)
var (
@ -101,7 +102,7 @@ func newReplicaSet(replicas int, selectorMap map[string]string) *apps.ReplicaSet
ResourceVersion: "18",
},
Spec: apps.ReplicaSetSpec{
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Selector: &metav1.LabelSelector{MatchLabels: selectorMap},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{

View File

@ -36,6 +36,7 @@ import (
v1 "k8s.io/api/core/v1"
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
"k8s.io/kubernetes/pkg/controller/history"
"k8s.io/utils/pointer"
)
// noopRecorder is an EventRecorder that does nothing. record.FakeRecorder has a fixed
@ -838,7 +839,7 @@ func newStatefulSetWithVolumes(replicas int, name string, petMounts []v1.VolumeM
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"foo": "bar"},
},
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
Template: template,
VolumeClaimTemplates: claims,
ServiceName: "governingsvc",
@ -893,7 +894,7 @@ func newStatefulSetWithLabels(replicas int, name string, uid types.UID, labels m
MatchLabels: nil,
MatchExpressions: testMatchExpressions,
},
Replicas: func() *int32 { i := int32(replicas); return &i }(),
Replicas: pointer.Int32(int32(replicas)),
PersistentVolumeClaimRetentionPolicy: &apps.StatefulSetPersistentVolumeClaimRetentionPolicy{
WhenScaled: apps.RetainPersistentVolumeClaimRetentionPolicyType,
WhenDeleted: apps.RetainPersistentVolumeClaimRetentionPolicyType,