Use Int32Ptr function from utils instead of self-written versions
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
_ "k8s.io/kubernetes/pkg/apis/core/install"
|
||||
_ "k8s.io/kubernetes/pkg/apis/extensions/install"
|
||||
. "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
|
||||
)
|
||||
|
||||
func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
@@ -81,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
|
||||
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -94,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
},
|
||||
Spec: extensionsv1beta1.DaemonSetSpec{
|
||||
Template: defaultTemplate,
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
expected: &extensionsv1beta1.DaemonSet{
|
||||
@@ -111,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
|
||||
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(1),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -123,7 +124,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
|
||||
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -137,7 +138,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
|
||||
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
|
||||
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
RevisionHistoryLimit: newInt32(10),
|
||||
RevisionHistoryLimit: utilpointer.Int32Ptr(10),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -179,7 +180,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
original: &extensionsv1beta1.Deployment{},
|
||||
expected: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(1),
|
||||
Replicas: utilpointer.Int32Ptr(1),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
|
||||
@@ -194,7 +195,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
|
||||
MaxSurge: &differentIntOrString,
|
||||
@@ -204,7 +205,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
|
||||
@@ -219,7 +220,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: nil,
|
||||
@@ -228,7 +229,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
|
||||
@@ -243,7 +244,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
@@ -251,7 +252,7 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
},
|
||||
expected: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
@@ -262,21 +263,21 @@ func TestSetDefaultDeployment(t *testing.T) {
|
||||
{
|
||||
original: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
},
|
||||
},
|
||||
expected: &extensionsv1beta1.Deployment{
|
||||
Spec: extensionsv1beta1.DeploymentSpec{
|
||||
Replicas: newInt32(5),
|
||||
Replicas: utilpointer.Int32Ptr(5),
|
||||
Strategy: extensionsv1beta1.DeploymentStrategy{
|
||||
Type: extensionsv1beta1.RecreateDeploymentStrategyType,
|
||||
},
|
||||
Template: defaultTemplate,
|
||||
ProgressDeadlineSeconds: newInt32(30),
|
||||
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -432,7 +433,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: extensionsv1beta1.ReplicaSet{
|
||||
Spec: extensionsv1beta1.ReplicaSetSpec{
|
||||
Replicas: newInt32(0),
|
||||
Replicas: utilpointer.Int32Ptr(0),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -447,7 +448,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
|
||||
{
|
||||
rs: extensionsv1beta1.ReplicaSet{
|
||||
Spec: extensionsv1beta1.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -490,7 +491,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
|
||||
}
|
||||
rs := &extensionsv1beta1.ReplicaSet{
|
||||
Spec: extensionsv1beta1.ReplicaSetSpec{
|
||||
Replicas: newInt32(3),
|
||||
Replicas: utilpointer.Int32Ptr(3),
|
||||
Template: v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
@@ -742,9 +743,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