Use Int32Ptr function from utils instead of self-written versions
This commit is contained in:
@@ -28,10 +28,11 @@ import (
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestV12StatefulSetSpecConversion(t *testing.T) {
|
||||
replicas := newInt32(2)
|
||||
replicas := utilpointer.Int32Ptr(2)
|
||||
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
|
||||
appsv1Template := v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
@@ -177,7 +178,7 @@ func TestV1StatefulSetStatusConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1StatefulSetUpdateStrategyConversion(t *testing.T) {
|
||||
partition := newInt32(2)
|
||||
partition := utilpointer.Int32Ptr(2)
|
||||
appsv1rollingUpdate := new(appsv1.RollingUpdateStatefulSetStrategy)
|
||||
appsv1rollingUpdate.Partition = partition
|
||||
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
|
||||
@@ -258,7 +259,7 @@ func TestV1RollingUpdateDaemonSetConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1DeploymentConversion(t *testing.T) {
|
||||
replica := newInt32(2)
|
||||
replica := utilpointer.Int32Ptr(2)
|
||||
rollbackTo := new(extensions.RollbackConfig)
|
||||
rollbackTo.Revision = int64(2)
|
||||
testcases := map[string]struct {
|
||||
@@ -337,9 +338,9 @@ func TestV1DeploymentConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1DeploymentSpecConversion(t *testing.T) {
|
||||
replica := newInt32(2)
|
||||
revisionHistoryLimit := newInt32(2)
|
||||
progressDeadlineSeconds := newInt32(2)
|
||||
replica := utilpointer.Int32Ptr(2)
|
||||
revisionHistoryLimit := utilpointer.Int32Ptr(2)
|
||||
progressDeadlineSeconds := utilpointer.Int32Ptr(2)
|
||||
|
||||
testcases := map[string]struct {
|
||||
deploymentSpec1 *extensions.DeploymentSpec
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
. "k8s.io/kubernetes/pkg/apis/apps/v1"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
@@ -81,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -94,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
},
|
||||
Spec: appsv1.DaemonSetSpec{
|
||||
Template: defaultTemplate,
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
expected: &appsv1.DaemonSet{
|
||||
@@ -111,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -130,7 +131,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
|
||||
Type: appsv1.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -147,7 +148,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -211,7 +212,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
Partition: &defaultPartition,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -235,7 +236,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
|
||||
Type: appsv1.OnDeleteStatefulSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -260,7 +261,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
Partition: &defaultPartition,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -302,7 +303,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
original: &appsv1.Deployment{},
|
||||
expected: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(1),
|
||||
Replicas: utilpointer.Int32Ptr(1),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1.RollingUpdateDeployment{
|
||||
@@ -310,8 +311,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -319,7 +320,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
RollingUpdate: &appsv1.RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
@@ -329,7 +330,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1.RollingUpdateDeployment{
|
||||
@@ -337,8 +338,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -346,7 +347,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: nil,
|
||||
@@ -355,7 +356,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1.RollingUpdateDeployment{
|
||||
@@ -363,8 +364,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -372,21 +373,21 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
},
|
||||
},
|
||||
expected: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -394,22 +395,22 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
},
|
||||
},
|
||||
expected: &appsv1.Deployment{
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -466,7 +467,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: appsv1.ReplicaSet{
|
||||
Spec: appsv1.ReplicaSetSpec{
|
||||
Replicas: newInt32(0),
|
||||
Replicas: utilpointer.Int32Ptr(0),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -481,7 +482,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: appsv1.ReplicaSet{
|
||||
Spec: appsv1.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -524,7 +525,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
|
||||
}
|
||||
rs := &appsv1.ReplicaSet{
|
||||
Spec: appsv1.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -563,9 +564,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
}
|
||||
return obj3
|
||||
}
|
||||
|
||||
func newInt32(val int32) *int32 {
|
||||
p := new(int32)
|
||||
*p = val
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
. "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestSetDefaultDeployment(t *testing.T) {
|
||||
@@ -54,7 +55,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
original: &appsv1beta1.Deployment{},
|
||||
expected: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(1),
|
||||
Replicas: utilpointer.Int32Ptr(1),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
|
||||
@@ -62,8 +63,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -71,7 +72,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
@@ -81,7 +82,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
|
||||
@@ -89,8 +90,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -98,7 +99,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: nil,
|
||||
@@ -107,7 +108,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
|
||||
@@ -115,8 +116,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -124,21 +125,21 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
},
|
||||
},
|
||||
expected: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -146,22 +147,22 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
},
|
||||
},
|
||||
expected: &appsv1beta1.Deployment{
|
||||
Spec: appsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta1.DeploymentStrategy{
|
||||
Type: appsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -215,9 +216,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
}
|
||||
return obj3
|
||||
}
|
||||
|
||||
func newInt32(val int32) *int32 {
|
||||
p := new(int32)
|
||||
*p = val
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -30,10 +30,11 @@ import (
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
|
||||
replicas := newInt32(2)
|
||||
replicas := utilpointer.Int32Ptr(2)
|
||||
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
|
||||
v1beta2Template := v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "foo"},
|
||||
@@ -104,7 +105,7 @@ func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1beta2StatefulSetUpdateStrategyConversion(t *testing.T) {
|
||||
partition := newInt32(2)
|
||||
partition := utilpointer.Int32Ptr(2)
|
||||
v1beta2rollingUpdate := new(v1beta2.RollingUpdateStatefulSetStrategy)
|
||||
v1beta2rollingUpdate.Partition = partition
|
||||
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
|
||||
@@ -260,7 +261,7 @@ func TestV1beta2StatefulSetStatusConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1beta2DeploymentConversion(t *testing.T) {
|
||||
replica := newInt32(2)
|
||||
replica := utilpointer.Int32Ptr(2)
|
||||
rollbackTo := new(extensions.RollbackConfig)
|
||||
rollbackTo.Revision = int64(2)
|
||||
testcases := map[string]struct {
|
||||
@@ -390,9 +391,9 @@ func TestV1beta2ScaleStatusConversion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestV1beta2DeploymentSpecConversion(t *testing.T) {
|
||||
replica := newInt32(2)
|
||||
revisionHistoryLimit := newInt32(2)
|
||||
progressDeadlineSeconds := newInt32(2)
|
||||
replica := utilpointer.Int32Ptr(2)
|
||||
revisionHistoryLimit := utilpointer.Int32Ptr(2)
|
||||
progressDeadlineSeconds := utilpointer.Int32Ptr(2)
|
||||
|
||||
testcases := map[string]struct {
|
||||
deploymentSpec1 *extensions.DeploymentSpec
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
. "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
@@ -81,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -94,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
},
|
||||
Spec: appsv1beta2.DaemonSetSpec{
|
||||
Template: defaultTemplate,
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
expected: &appsv1beta2.DaemonSet{
|
||||
@@ -111,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -130,7 +131,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: appsv1beta2.DaemonSetUpdateStrategy{
|
||||
Type: appsv1beta2.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -147,7 +148,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
MaxUnavailable: &maxUnavailable,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -211,7 +212,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
Partition: &defaultPartition,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -235,7 +236,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{
|
||||
Type: appsv1beta2.OnDeleteStatefulSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -260,7 +261,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
|
||||
Partition: &defaultPartition,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -302,7 +303,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
original: &appsv1beta2.Deployment{},
|
||||
expected: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(1),
|
||||
Replicas: utilpointer.Int32Ptr(1),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
|
||||
@@ -310,8 +311,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -319,7 +320,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
@@ -329,7 +330,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
|
||||
@@ -337,8 +338,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -346,7 +347,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: nil,
|
||||
@@ -355,7 +356,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
|
||||
@@ -363,8 +364,8 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
MaxUnavailable: &defaultIntOrString,
|
||||
},
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -372,21 +373,21 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
},
|
||||
},
|
||||
expected: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RecreateDeploymentStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(0),
|
||||
ProgressDeadlineSeconds: newInt32(600),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(0),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -394,22 +395,22 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
},
|
||||
},
|
||||
expected: &appsv1beta2.Deployment{
|
||||
Spec: appsv1beta2.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: appsv1beta2.DeploymentStrategy{
|
||||
Type: appsv1beta2.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
RevisionHistoryLimit: newInt32(2),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(2),
|
||||
Template: defaultTemplate,
|
||||
},
|
||||
},
|
||||
@@ -466,7 +467,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: appsv1beta2.ReplicaSet{
|
||||
Spec: appsv1beta2.ReplicaSetSpec{
|
||||
Replicas: newInt32(0),
|
||||
Replicas: utilpointer.Int32Ptr(0),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -481,7 +482,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: appsv1beta2.ReplicaSet{
|
||||
Spec: appsv1beta2.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -524,7 +525,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
|
||||
}
|
||||
rs := &appsv1beta2.ReplicaSet{
|
||||
Spec: appsv1beta2.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -563,9 +564,3 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
|
||||
}
|
||||
return obj3
|
||||
}
|
||||
|
||||
func newInt32(val int32) *int32 {
|
||||
p := new(int32)
|
||||
*p = val
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user