Merge pull request #114902 from TommyStarK/pkg-apis/replace-deprecated-pointer-function

pkg/apis: Replace deprecated pointer function
This commit is contained in:
Kubernetes Prow Robot 2023-03-09 21:34:15 -08:00 committed by GitHub
commit 48e4052fc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 396 additions and 396 deletions

View File

@ -90,6 +90,6 @@ func SetDefaults_Rule(obj *admissionregistrationv1.Rule) {
// SetDefaults_ServiceReference sets defaults for Webhook's ServiceReference // SetDefaults_ServiceReference sets defaults for Webhook's ServiceReference
func SetDefaults_ServiceReference(obj *admissionregistrationv1.ServiceReference) { func SetDefaults_ServiceReference(obj *admissionregistrationv1.ServiceReference) {
if obj.Port == nil { if obj.Port == nil {
obj.Port = utilpointer.Int32Ptr(443) obj.Port = utilpointer.Int32(443)
} }
} }

View File

@ -107,7 +107,7 @@ func TestDefaultAdmissionWebhook(t *testing.T) {
Webhooks: []v1.MutatingWebhook{{ Webhooks: []v1.MutatingWebhook{{
ClientConfig: v1.WebhookClientConfig{ ClientConfig: v1.WebhookClientConfig{
Service: &v1.ServiceReference{ Service: &v1.ServiceReference{
Port: utilpointer.Int32Ptr(443), // defaulted Port: utilpointer.Int32(443), // defaulted
}, },
}, },
FailurePolicy: &fail, FailurePolicy: &fail,

View File

@ -100,6 +100,6 @@ func SetDefaults_MutatingWebhook(obj *admissionregistrationv1beta1.MutatingWebho
// SetDefaults_ServiceReference sets defaults for Webhook's ServiceReference // SetDefaults_ServiceReference sets defaults for Webhook's ServiceReference
func SetDefaults_ServiceReference(obj *admissionregistrationv1beta1.ServiceReference) { func SetDefaults_ServiceReference(obj *admissionregistrationv1beta1.ServiceReference) {
if obj.Port == nil { if obj.Port == nil {
obj.Port = utilpointer.Int32Ptr(443) obj.Port = utilpointer.Int32(443)
} }
} }

View File

@ -114,7 +114,7 @@ func TestDefaultAdmissionWebhook(t *testing.T) {
Webhooks: []v1beta1.MutatingWebhook{{ Webhooks: []v1beta1.MutatingWebhook{{
ClientConfig: v1beta1.WebhookClientConfig{ ClientConfig: v1beta1.WebhookClientConfig{
Service: &v1beta1.ServiceReference{ Service: &v1beta1.ServiceReference{
Port: utilpointer.Int32Ptr(443), // defaulted Port: utilpointer.Int32(443), // defaulted
}, },
}, },
FailurePolicy: &ignore, FailurePolicy: &ignore,

View File

@ -31,7 +31,7 @@ import (
) )
func TestV12StatefulSetSpecConversion(t *testing.T) { func TestV12StatefulSetSpecConversion(t *testing.T) {
replicas := utilpointer.Int32Ptr(2) replicas := utilpointer.Int32(2)
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}} selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
appsv1Template := v1.PodTemplateSpec{ appsv1Template := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "foo"}, ObjectMeta: metav1.ObjectMeta{Name: "foo"},
@ -177,7 +177,7 @@ func TestV1StatefulSetStatusConversion(t *testing.T) {
} }
func TestV1StatefulSetUpdateStrategyConversion(t *testing.T) { func TestV1StatefulSetUpdateStrategyConversion(t *testing.T) {
partition := utilpointer.Int32Ptr(2) partition := utilpointer.Int32(2)
appsv1rollingUpdate := new(appsv1.RollingUpdateStatefulSetStrategy) appsv1rollingUpdate := new(appsv1.RollingUpdateStatefulSetStrategy)
appsv1rollingUpdate.Partition = partition appsv1rollingUpdate.Partition = partition
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy) appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
@ -259,7 +259,7 @@ func TestV1RollingUpdateDaemonSetConversion(t *testing.T) {
} }
func TestV1DeploymentConversion(t *testing.T) { func TestV1DeploymentConversion(t *testing.T) {
replica := utilpointer.Int32Ptr(2) replica := utilpointer.Int32(2)
rollbackTo := new(apps.RollbackConfig) rollbackTo := new(apps.RollbackConfig)
rollbackTo.Revision = int64(2) rollbackTo.Revision = int64(2)
testcases := map[string]struct { testcases := map[string]struct {
@ -338,9 +338,9 @@ func TestV1DeploymentConversion(t *testing.T) {
} }
func TestV1DeploymentSpecConversion(t *testing.T) { func TestV1DeploymentSpecConversion(t *testing.T) {
replica := utilpointer.Int32Ptr(2) replica := utilpointer.Int32(2)
revisionHistoryLimit := utilpointer.Int32Ptr(2) revisionHistoryLimit := utilpointer.Int32(2)
progressDeadlineSeconds := utilpointer.Int32Ptr(2) progressDeadlineSeconds := utilpointer.Int32(2)
testcases := map[string]struct { testcases := map[string]struct {
deploymentSpec1 *apps.DeploymentSpec deploymentSpec1 *apps.DeploymentSpec

View File

@ -86,7 +86,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -99,7 +99,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
}, },
Spec: appsv1.DaemonSetSpec{ Spec: appsv1.DaemonSetSpec{
Template: defaultTemplate, Template: defaultTemplate,
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
expected: &appsv1.DaemonSet{ expected: &appsv1.DaemonSet{
@ -117,7 +117,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
}, },
@ -136,7 +136,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{ UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
Type: appsv1.OnDeleteDaemonSetStrategyType, Type: appsv1.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -154,7 +154,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -233,7 +233,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition, Partition: &defaultPartition,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -259,7 +259,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ UpdateStrategy: appsv1.StatefulSetUpdateStrategy{
Type: appsv1.OnDeleteStatefulSetStrategyType, Type: appsv1.OnDeleteStatefulSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -286,7 +286,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition, Partition: &defaultPartition,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -317,7 +317,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &notTheDefaultPartition, Partition: &notTheDefaultPartition,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -346,7 +346,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType,
WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enablePVCDeletionPolicy: true, enablePVCDeletionPolicy: true,
@ -379,7 +379,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType,
WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enablePVCDeletionPolicy: true, enablePVCDeletionPolicy: true,
@ -412,7 +412,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
WhenDeleted: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, WhenDeleted: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enablePVCDeletionPolicy: true, enablePVCDeletionPolicy: true,
@ -444,7 +444,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ PersistentVolumeClaimRetentionPolicy: &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{
WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType, WhenScaled: appsv1.DeletePersistentVolumeClaimRetentionPolicyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enablePVCDeletionPolicy: false, enablePVCDeletionPolicy: false,
@ -470,7 +470,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: getPartition(0), Partition: getPartition(0),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -503,7 +503,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(1), MaxUnavailable: getMaxUnavailable(1),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -536,7 +536,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(3), MaxUnavailable: getMaxUnavailable(3),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -563,7 +563,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(1), MaxUnavailable: getMaxUnavailable(1),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: true, enableMaxUnavailablePolicy: true,
@ -596,7 +596,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(3), MaxUnavailable: getMaxUnavailable(3),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: true, enableMaxUnavailablePolicy: true,
@ -643,7 +643,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1.Deployment{}, original: &appsv1.Deployment{},
expected: &appsv1.Deployment{ expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(1), Replicas: utilpointer.Int32(1),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType, Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{ RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -651,8 +651,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -660,7 +660,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1.Deployment{ original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
RollingUpdate: &appsv1.RollingUpdateDeployment{ RollingUpdate: &appsv1.RollingUpdateDeployment{
MaxSurge: &differentIntOrString, MaxSurge: &differentIntOrString,
@ -670,7 +670,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1.Deployment{ expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType, Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{ RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -678,8 +678,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -687,7 +687,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1.Deployment{ original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType, Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil, RollingUpdate: nil,
@ -696,7 +696,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1.Deployment{ expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RollingUpdateDeploymentStrategyType, Type: appsv1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1.RollingUpdateDeployment{ RollingUpdate: &appsv1.RollingUpdateDeployment{
@ -704,8 +704,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -713,21 +713,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1.Deployment{ original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType, Type: appsv1.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
}, },
}, },
expected: &appsv1.Deployment{ expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType, Type: appsv1.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -735,22 +735,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1.Deployment{ original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType, Type: appsv1.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
}, },
}, },
expected: &appsv1.Deployment{ expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{ Spec: appsv1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1.DeploymentStrategy{ Strategy: appsv1.DeploymentStrategy{
Type: appsv1.RecreateDeploymentStrategyType, Type: appsv1.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -807,7 +807,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: appsv1.ReplicaSet{ rs: appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{ Spec: appsv1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(0), Replicas: utilpointer.Int32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -822,7 +822,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: appsv1.ReplicaSet{ rs: appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{ Spec: appsv1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -865,7 +865,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
} }
rs := &appsv1.ReplicaSet{ rs := &appsv1.ReplicaSet{
Spec: appsv1.ReplicaSetSpec{ Spec: appsv1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{

View File

@ -54,7 +54,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1beta1.Deployment{}, original: &appsv1beta1.Deployment{},
expected: &appsv1beta1.Deployment{ expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(1), Replicas: utilpointer.Int32(1),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType, Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{ RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -62,8 +62,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -71,7 +71,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta1.Deployment{ original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{ RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
MaxSurge: &differentIntOrString, MaxSurge: &differentIntOrString,
@ -81,7 +81,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1beta1.Deployment{ expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType, Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{ RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -89,8 +89,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -98,7 +98,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta1.Deployment{ original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType, Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil, RollingUpdate: nil,
@ -107,7 +107,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1beta1.Deployment{ expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RollingUpdateDeploymentStrategyType, Type: appsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta1.RollingUpdateDeployment{ RollingUpdate: &appsv1beta1.RollingUpdateDeployment{
@ -115,8 +115,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -124,21 +124,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta1.Deployment{ original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType, Type: appsv1beta1.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
}, },
}, },
expected: &appsv1beta1.Deployment{ expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType, Type: appsv1beta1.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -146,22 +146,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta1.Deployment{ original: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType, Type: appsv1beta1.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
}, },
}, },
expected: &appsv1beta1.Deployment{ expected: &appsv1beta1.Deployment{
Spec: appsv1beta1.DeploymentSpec{ Spec: appsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta1.DeploymentStrategy{ Strategy: appsv1beta1.DeploymentStrategy{
Type: appsv1beta1.RecreateDeploymentStrategyType, Type: appsv1beta1.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },

View File

@ -33,7 +33,7 @@ import (
) )
func TestV1beta2StatefulSetSpecConversion(t *testing.T) { func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
replicas := utilpointer.Int32Ptr(2) replicas := utilpointer.Int32(2)
selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}} selector := &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}
v1beta2Template := v1.PodTemplateSpec{ v1beta2Template := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "foo"}, ObjectMeta: metav1.ObjectMeta{Name: "foo"},
@ -104,7 +104,7 @@ func TestV1beta2StatefulSetSpecConversion(t *testing.T) {
} }
func TestV1beta2StatefulSetUpdateStrategyConversion(t *testing.T) { func TestV1beta2StatefulSetUpdateStrategyConversion(t *testing.T) {
partition := utilpointer.Int32Ptr(2) partition := utilpointer.Int32(2)
v1beta2rollingUpdate := new(v1beta2.RollingUpdateStatefulSetStrategy) v1beta2rollingUpdate := new(v1beta2.RollingUpdateStatefulSetStrategy)
v1beta2rollingUpdate.Partition = partition v1beta2rollingUpdate.Partition = partition
appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy) appsrollingUpdate := new(apps.RollingUpdateStatefulSetStrategy)
@ -261,7 +261,7 @@ func TestV1beta2StatefulSetStatusConversion(t *testing.T) {
} }
func TestV1beta2DeploymentConversion(t *testing.T) { func TestV1beta2DeploymentConversion(t *testing.T) {
replica := utilpointer.Int32Ptr(2) replica := utilpointer.Int32(2)
rollbackTo := new(apps.RollbackConfig) rollbackTo := new(apps.RollbackConfig)
rollbackTo.Revision = int64(2) rollbackTo.Revision = int64(2)
testcases := map[string]struct { testcases := map[string]struct {
@ -391,9 +391,9 @@ func TestV1beta2ScaleStatusConversion(t *testing.T) {
} }
func TestV1beta2DeploymentSpecConversion(t *testing.T) { func TestV1beta2DeploymentSpecConversion(t *testing.T) {
replica := utilpointer.Int32Ptr(2) replica := utilpointer.Int32(2)
revisionHistoryLimit := utilpointer.Int32Ptr(2) revisionHistoryLimit := utilpointer.Int32(2)
progressDeadlineSeconds := utilpointer.Int32Ptr(2) progressDeadlineSeconds := utilpointer.Int32(2)
testcases := map[string]struct { testcases := map[string]struct {
deploymentSpec1 *apps.DeploymentSpec deploymentSpec1 *apps.DeploymentSpec

View File

@ -86,7 +86,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -99,7 +99,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
}, },
Spec: appsv1beta2.DaemonSetSpec{ Spec: appsv1beta2.DaemonSetSpec{
Template: defaultTemplate, Template: defaultTemplate,
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
expected: &appsv1beta2.DaemonSet{ expected: &appsv1beta2.DaemonSet{
@ -117,7 +117,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
}, },
@ -136,7 +136,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: appsv1beta2.DaemonSetUpdateStrategy{ UpdateStrategy: appsv1beta2.DaemonSetUpdateStrategy{
Type: appsv1beta2.OnDeleteDaemonSetStrategyType, Type: appsv1beta2.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -154,7 +154,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
MaxSurge: &maxSurge, MaxSurge: &maxSurge,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -232,7 +232,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition, Partition: &defaultPartition,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -258,7 +258,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{ UpdateStrategy: appsv1beta2.StatefulSetUpdateStrategy{
Type: appsv1beta2.OnDeleteStatefulSetStrategyType, Type: appsv1beta2.OnDeleteStatefulSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -285,7 +285,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: &defaultPartition, Partition: &defaultPartition,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -310,7 +310,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
Partition: getPartition(0), Partition: getPartition(0),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -343,7 +343,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(1), MaxUnavailable: getMaxUnavailable(1),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -376,7 +376,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(3), MaxUnavailable: getMaxUnavailable(3),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: false, enableMaxUnavailablePolicy: false,
@ -403,7 +403,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(1), MaxUnavailable: getMaxUnavailable(1),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: true, enableMaxUnavailablePolicy: true,
@ -436,7 +436,7 @@ func TestSetDefaultStatefulSet(t *testing.T) {
MaxUnavailable: getMaxUnavailable(3), MaxUnavailable: getMaxUnavailable(3),
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
enableMaxUnavailablePolicy: true, enableMaxUnavailablePolicy: true,
@ -481,7 +481,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &appsv1beta2.Deployment{}, original: &appsv1beta2.Deployment{},
expected: &appsv1beta2.Deployment{ expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(1), Replicas: utilpointer.Int32(1),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType, Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{ RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -489,8 +489,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -498,7 +498,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta2.Deployment{ original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{ RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
MaxSurge: &differentIntOrString, MaxSurge: &differentIntOrString,
@ -508,7 +508,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1beta2.Deployment{ expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType, Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{ RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -516,8 +516,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -525,7 +525,7 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta2.Deployment{ original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType, Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil, RollingUpdate: nil,
@ -534,7 +534,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &appsv1beta2.Deployment{ expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RollingUpdateDeploymentStrategyType, Type: appsv1beta2.RollingUpdateDeploymentStrategyType,
RollingUpdate: &appsv1beta2.RollingUpdateDeployment{ RollingUpdate: &appsv1beta2.RollingUpdateDeployment{
@ -542,8 +542,8 @@ func TestSetDefaultDeployment(t *testing.T) {
MaxUnavailable: &defaultIntOrString, MaxUnavailable: &defaultIntOrString,
}, },
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -551,21 +551,21 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta2.Deployment{ original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType, Type: appsv1beta2.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
}, },
}, },
expected: &appsv1beta2.Deployment{ expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType, Type: appsv1beta2.RecreateDeploymentStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(0), RevisionHistoryLimit: utilpointer.Int32(0),
ProgressDeadlineSeconds: utilpointer.Int32Ptr(600), ProgressDeadlineSeconds: utilpointer.Int32(600),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -573,22 +573,22 @@ func TestSetDefaultDeployment(t *testing.T) {
{ {
original: &appsv1beta2.Deployment{ original: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType, Type: appsv1beta2.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
}, },
}, },
expected: &appsv1beta2.Deployment{ expected: &appsv1beta2.Deployment{
Spec: appsv1beta2.DeploymentSpec{ Spec: appsv1beta2.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: appsv1beta2.DeploymentStrategy{ Strategy: appsv1beta2.DeploymentStrategy{
Type: appsv1beta2.RecreateDeploymentStrategyType, Type: appsv1beta2.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(2), RevisionHistoryLimit: utilpointer.Int32(2),
Template: defaultTemplate, Template: defaultTemplate,
}, },
}, },
@ -645,7 +645,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: appsv1beta2.ReplicaSet{ rs: appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{ Spec: appsv1beta2.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(0), Replicas: utilpointer.Int32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -660,7 +660,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: appsv1beta2.ReplicaSet{ rs: appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{ Spec: appsv1beta2.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -703,7 +703,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
} }
rs := &appsv1beta2.ReplicaSet{ rs := &appsv1beta2.ReplicaSet{
Spec: appsv1beta2.ReplicaSetSpec{ Spec: appsv1beta2.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{

View File

@ -46,7 +46,7 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
"TestConversionWithCPUAverageValueAndUtilizationBoth1", "TestConversionWithCPUAverageValueAndUtilizationBoth1",
args{ args{
in: &autoscaling.HorizontalPodAutoscalerSpec{ in: &autoscaling.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -65,7 +65,7 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -73,9 +73,9 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
}, },
out: &autoscalingv1.HorizontalPodAutoscalerSpec{}, out: &autoscalingv1.HorizontalPodAutoscalerSpec{},
expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{ expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(70), TargetCPUUtilizationPercentage: utilpointer.Int32(70),
}, },
s: nil, s: nil,
}, },
@ -85,7 +85,7 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
"TestConversionWithCPUAverageValueAndUtilizationBoth2", "TestConversionWithCPUAverageValueAndUtilizationBoth2",
args{ args{
in: &autoscaling.HorizontalPodAutoscalerSpec{ in: &autoscaling.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -104,21 +104,21 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
}, },
}, },
out: &autoscalingv1.HorizontalPodAutoscalerSpec{ out: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(2), MinReplicas: utilpointer.Int32(2),
MaxReplicas: 4, MaxReplicas: 4,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(60), TargetCPUUtilizationPercentage: utilpointer.Int32(60),
}, },
expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{ expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(70), TargetCPUUtilizationPercentage: utilpointer.Int32(70),
}, },
s: nil, s: nil,
}, },
@ -128,19 +128,19 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
"TestConversionWithoutMetrics", "TestConversionWithoutMetrics",
args{ args{
in: &autoscaling.HorizontalPodAutoscalerSpec{ in: &autoscaling.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
Metrics: []autoscaling.MetricSpec{}, Metrics: []autoscaling.MetricSpec{},
}, },
out: &autoscalingv1.HorizontalPodAutoscalerSpec{ out: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 4, MaxReplicas: 4,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(60), TargetCPUUtilizationPercentage: utilpointer.Int32(60),
}, },
expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{ expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(60), TargetCPUUtilizationPercentage: utilpointer.Int32(60),
}, },
s: nil, s: nil,
}, },
@ -150,7 +150,7 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
"TestConversionWithCPUUtilizationOnly", "TestConversionWithCPUUtilizationOnly",
args{ args{
in: &autoscaling.HorizontalPodAutoscalerSpec{ in: &autoscaling.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -159,7 +159,7 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(60), AverageUtilization: utilpointer.Int32(60),
}, },
}, },
}, },
@ -167,9 +167,9 @@ func TestConvert_autoscaling_HorizontalPodAutoscalerSpec_To_v1_HorizontalPodAuto
}, },
out: &autoscalingv1.HorizontalPodAutoscalerSpec{}, out: &autoscalingv1.HorizontalPodAutoscalerSpec{},
expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{ expectOut: &autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 3, MaxReplicas: 3,
TargetCPUUtilizationPercentage: utilpointer.Int32Ptr(60), TargetCPUUtilizationPercentage: utilpointer.Int32(60),
}, },
s: nil, s: nil,
}, },

View File

@ -46,7 +46,7 @@ func TestSetDefaultHPA(t *testing.T) {
{ {
hpa: autoscalingv1.HorizontalPodAutoscaler{ hpa: autoscalingv1.HorizontalPodAutoscaler{
Spec: autoscalingv1.HorizontalPodAutoscalerSpec{ Spec: autoscalingv1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(3), MinReplicas: utilpointer.Int32(3),
}, },
}, },
expectReplicas: 3, expectReplicas: 3,

View File

@ -65,13 +65,13 @@ func TestGenerateScaleDownRules(t *testing.T) {
rateDownPodsPeriodSeconds: 2, rateDownPodsPeriodSeconds: 2,
rateDownPercent: 3, rateDownPercent: 3,
rateDownPercentPeriodSeconds: 4, rateDownPercentPeriodSeconds: 4,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
selectPolicy: &maxPolicy, selectPolicy: &maxPolicy,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4}, {Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
{ {
@ -147,7 +147,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
{Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 15}, {Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 15},
{Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15}, {Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
{ {
@ -156,13 +156,13 @@ func TestGenerateScaleUpRules(t *testing.T) {
rateUpPodsPeriodSeconds: 2, rateUpPodsPeriodSeconds: 2,
rateUpPercent: 3, rateUpPercent: 3,
rateUpPercentPeriodSeconds: 4, rateUpPercentPeriodSeconds: 4,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
selectPolicy: &maxPolicy, selectPolicy: &maxPolicy,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4}, {Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
{ {
@ -173,7 +173,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MinChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MinChangePolicySelect),
}, },
{ {
@ -183,29 +183,29 @@ func TestGenerateScaleUpRules(t *testing.T) {
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 10}, {Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 10},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
{ {
annotation: "Pod policy and stabilization window are specified", annotation: "Pod policy and stabilization window are specified",
rateUpPodsPeriodSeconds: 2, rateUpPodsPeriodSeconds: 2,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
rateUpPods: 4, rateUpPods: 4,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 2},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
{ {
annotation: "Percent policy and stabilization window are specified", annotation: "Percent policy and stabilization window are specified",
rateUpPercent: 7, rateUpPercent: 7,
rateUpPercentPeriodSeconds: 60, rateUpPercentPeriodSeconds: 60,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 60}, {Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 60},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxChangePolicySelect),
}, },
} }

View File

@ -37,7 +37,7 @@ import (
func TestSetDefaultHPA(t *testing.T) { func TestSetDefaultHPA(t *testing.T) {
utilizationDefaultVal := int32(autoscaling.DefaultCPUUtilization) utilizationDefaultVal := int32(autoscaling.DefaultCPUUtilization)
defaultReplicas := utilpointer.Int32Ptr(1) defaultReplicas := utilpointer.Int32(1)
defaultTemplate := []autoscalingv2beta1.MetricSpec{ defaultTemplate := []autoscalingv2beta1.MetricSpec{
{ {
Type: autoscalingv2beta1.ResourceMetricSourceType, Type: autoscalingv2beta1.ResourceMetricSourceType,
@ -68,13 +68,13 @@ func TestSetDefaultHPA(t *testing.T) {
{ // MinReplicas update { // MinReplicas update
original: &autoscalingv2beta1.HorizontalPodAutoscaler{ original: &autoscalingv2beta1.HorizontalPodAutoscaler{
Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{ Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(3), MinReplicas: utilpointer.Int32(3),
Metrics: defaultTemplate, Metrics: defaultTemplate,
}, },
}, },
expected: &autoscalingv2beta1.HorizontalPodAutoscaler{ expected: &autoscalingv2beta1.HorizontalPodAutoscaler{
Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{ Spec: autoscalingv2beta1.HorizontalPodAutoscalerSpec{
MinReplicas: utilpointer.Int32Ptr(3), MinReplicas: utilpointer.Int32(3),
Metrics: defaultTemplate, Metrics: defaultTemplate,
}, },
}, },

View File

@ -65,13 +65,13 @@ func TestGenerateScaleDownRules(t *testing.T) {
rateDownPodsPeriodSeconds: 2, rateDownPodsPeriodSeconds: 2,
rateDownPercent: 3, rateDownPercent: 3,
rateDownPercentPeriodSeconds: 4, rateDownPercentPeriodSeconds: 4,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
selectPolicy: &maxPolicy, selectPolicy: &maxPolicy,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4}, {Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
{ {
@ -147,7 +147,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
{Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 15}, {Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 15},
{Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15}, {Type: autoscalingv2.PercentScalingPolicy, Value: 100, PeriodSeconds: 15},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
{ {
@ -156,13 +156,13 @@ func TestGenerateScaleUpRules(t *testing.T) {
rateUpPodsPeriodSeconds: 2, rateUpPodsPeriodSeconds: 2,
rateUpPercent: 3, rateUpPercent: 3,
rateUpPercentPeriodSeconds: 4, rateUpPercentPeriodSeconds: 4,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
selectPolicy: &maxPolicy, selectPolicy: &maxPolicy,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
{Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4}, {Type: autoscalingv2.PercentScalingPolicy, Value: 3, PeriodSeconds: 4},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
{ {
@ -173,7 +173,7 @@ func TestGenerateScaleUpRules(t *testing.T) {
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 1, PeriodSeconds: 2},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MinPolicySelect), expectedSelectPolicy: string(autoscalingv2.MinPolicySelect),
}, },
{ {
@ -183,29 +183,29 @@ func TestGenerateScaleUpRules(t *testing.T) {
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 10}, {Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 10},
}, },
expectedStabilization: utilpointer.Int32Ptr(0), expectedStabilization: utilpointer.Int32(0),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
{ {
annotation: "Pod policy and stabilization window are specified", annotation: "Pod policy and stabilization window are specified",
rateUpPodsPeriodSeconds: 2, rateUpPodsPeriodSeconds: 2,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
rateUpPods: 4, rateUpPods: 4,
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 2}, {Type: autoscalingv2.PodsScalingPolicy, Value: 4, PeriodSeconds: 2},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
{ {
annotation: "Percent policy and stabilization window are specified", annotation: "Percent policy and stabilization window are specified",
rateUpPercent: 7, rateUpPercent: 7,
rateUpPercentPeriodSeconds: 60, rateUpPercentPeriodSeconds: 60,
stabilizationSeconds: utilpointer.Int32Ptr(25), stabilizationSeconds: utilpointer.Int32(25),
expectedPolicies: []autoscalingv2.HPAScalingPolicy{ expectedPolicies: []autoscalingv2.HPAScalingPolicy{
{Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 60}, {Type: autoscalingv2.PercentScalingPolicy, Value: 7, PeriodSeconds: 60},
}, },
expectedStabilization: utilpointer.Int32Ptr(25), expectedStabilization: utilpointer.Int32(25),
expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect), expectedSelectPolicy: string(autoscalingv2.MaxPolicySelect),
}, },
} }

View File

@ -118,19 +118,19 @@ func TestValidateBehavior(t *testing.T) {
}, },
{ {
ScaleUp: &autoscaling.HPAScalingRules{ ScaleUp: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(3600), StabilizationWindowSeconds: utilpointer.Int32(3600),
SelectPolicy: &minPolicy, SelectPolicy: &minPolicy,
Policies: simplePoliciesList, Policies: simplePoliciesList,
}, },
ScaleDown: &autoscaling.HPAScalingRules{ ScaleDown: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(0), StabilizationWindowSeconds: utilpointer.Int32(0),
SelectPolicy: &disabledPolicy, SelectPolicy: &disabledPolicy,
Policies: simplePoliciesList, Policies: simplePoliciesList,
}, },
}, },
{ {
ScaleUp: &autoscaling.HPAScalingRules{ ScaleUp: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(120), StabilizationWindowSeconds: utilpointer.Int32(120),
SelectPolicy: &maxPolicy, SelectPolicy: &maxPolicy,
Policies: []autoscaling.HPAScalingPolicy{ Policies: []autoscaling.HPAScalingPolicy{
{ {
@ -156,7 +156,7 @@ func TestValidateBehavior(t *testing.T) {
}, },
}, },
ScaleDown: &autoscaling.HPAScalingRules{ ScaleDown: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(120), StabilizationWindowSeconds: utilpointer.Int32(120),
SelectPolicy: &maxPolicy, SelectPolicy: &maxPolicy,
Policies: []autoscaling.HPAScalingPolicy{ Policies: []autoscaling.HPAScalingPolicy{
{ {
@ -204,7 +204,7 @@ func TestValidateBehavior(t *testing.T) {
{ {
behavior: autoscaling.HorizontalPodAutoscalerBehavior{ behavior: autoscaling.HorizontalPodAutoscalerBehavior{
ScaleUp: &autoscaling.HPAScalingRules{ ScaleUp: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(3601), StabilizationWindowSeconds: utilpointer.Int32(3601),
SelectPolicy: &minPolicy, SelectPolicy: &minPolicy,
Policies: simplePoliciesList, Policies: simplePoliciesList,
}, },
@ -319,7 +319,7 @@ func TestValidateBehavior(t *testing.T) {
{ {
behavior: autoscaling.HorizontalPodAutoscalerBehavior{ behavior: autoscaling.HorizontalPodAutoscalerBehavior{
ScaleDown: &autoscaling.HPAScalingRules{ ScaleDown: &autoscaling.HPAScalingRules{
StabilizationWindowSeconds: utilpointer.Int32Ptr(3601), StabilizationWindowSeconds: utilpointer.Int32(3601),
SelectPolicy: &minPolicy, SelectPolicy: &minPolicy,
Policies: simplePoliciesList, Policies: simplePoliciesList,
}, },
@ -445,7 +445,7 @@ func prepareHPAWithBehavior(b autoscaling.HorizontalPodAutoscalerBehavior) autos
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -454,7 +454,7 @@ func prepareHPAWithBehavior(b autoscaling.HorizontalPodAutoscalerBehavior) autos
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -481,7 +481,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -490,7 +490,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -507,7 +507,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
}, },
}, },
@ -521,7 +521,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -547,7 +547,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -575,7 +575,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -585,7 +585,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-container", Container: "test-container",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -602,7 +602,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -629,7 +629,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -661,7 +661,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -690,7 +690,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -725,7 +725,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -734,7 +734,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -748,7 +748,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -758,7 +758,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -772,7 +772,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -781,7 +781,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -795,7 +795,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "..", Name: "myrc"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -805,7 +805,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -819,7 +819,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -828,7 +828,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -842,7 +842,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -852,7 +852,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -866,7 +866,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -875,7 +875,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -889,7 +889,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Kind: "ReplicationController", Name: ".."},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -899,7 +899,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -916,7 +916,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
MinReplicas: utilpointer.Int32Ptr(-1), MinReplicas: utilpointer.Int32(-1),
MaxReplicas: 5, MaxReplicas: 5,
}, },
}, },
@ -930,7 +930,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{},
MinReplicas: utilpointer.Int32Ptr(7), MinReplicas: utilpointer.Int32(7),
MaxReplicas: 5, MaxReplicas: 5,
}, },
}, },
@ -944,7 +944,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -953,7 +953,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI), AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
}, },
}, },
@ -971,7 +971,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
}, },
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -981,7 +981,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI), AverageValue: resource.NewMilliQuantity(300, resource.DecimalSI),
}, },
}, },
@ -996,7 +996,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1004,7 +1004,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Resource: &autoscaling.ResourceMetricSource{ Resource: &autoscaling.ResourceMetricSource{
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -1018,7 +1018,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1027,7 +1027,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -1041,7 +1041,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1051,7 +1051,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(70), AverageUtilization: utilpointer.Int32(70),
}, },
}, },
}, },
@ -1065,7 +1065,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1074,7 +1074,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(-10), AverageUtilization: utilpointer.Int32(-10),
}, },
}, },
}, },
@ -1088,7 +1088,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1098,7 +1098,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "test-application", Container: "test-application",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(-10), AverageUtilization: utilpointer.Int32(-10),
}, },
}, },
}, },
@ -1112,7 +1112,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1121,7 +1121,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Name: api.ResourceCPU, Name: api.ResourceCPU,
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(-10), AverageUtilization: utilpointer.Int32(-10),
}, },
}, },
}, },
@ -1135,7 +1135,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1145,7 +1145,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
Container: "---***", Container: "---***",
Target: autoscaling.MetricTarget{ Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType, Type: autoscaling.UtilizationMetricType,
AverageUtilization: utilpointer.Int32Ptr(-10), AverageUtilization: utilpointer.Int32(-10),
}, },
}, },
}, },
@ -1159,7 +1159,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1181,7 +1181,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1204,7 +1204,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1227,7 +1227,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1251,7 +1251,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1279,7 +1279,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1307,7 +1307,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1333,7 +1333,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1358,7 +1358,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1385,7 +1385,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1410,7 +1410,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1436,7 +1436,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1462,7 +1462,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1489,7 +1489,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1515,7 +1515,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1540,7 +1540,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1562,7 +1562,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{}, {},
@ -1576,7 +1576,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1592,7 +1592,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1690,7 +1690,7 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault}, ObjectMeta: metav1.ObjectMeta{Name: "myautoscaler", Namespace: metav1.NamespaceDefault},
Spec: autoscaling.HorizontalPodAutoscalerSpec{ Spec: autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"}, ScaleTargetRef: autoscaling.CrossVersionObjectReference{Name: "myrc", Kind: "ReplicationController"},
MinReplicas: utilpointer.Int32Ptr(1), MinReplicas: utilpointer.Int32(1),
MaxReplicas: 5, Metrics: []autoscaling.MetricSpec{spec}, MaxReplicas: 5, Metrics: []autoscaling.MetricSpec{spec},
}, },
}) })
@ -1723,7 +1723,7 @@ func prepareMinReplicasCases(t *testing.T, minReplicas int32) []autoscaling.Hori
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(minReplicas), MinReplicas: utilpointer.Int32(minReplicas),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1756,7 +1756,7 @@ func prepareMinReplicasCases(t *testing.T, minReplicas int32) []autoscaling.Hori
Kind: "ReplicationController", Kind: "ReplicationController",
Name: "myrc", Name: "myrc",
}, },
MinReplicas: utilpointer.Int32Ptr(minReplicas), MinReplicas: utilpointer.Int32(minReplicas),
MaxReplicas: 5, MaxReplicas: 5,
Metrics: []autoscaling.MetricSpec{ Metrics: []autoscaling.MetricSpec{
{ {
@ -1810,7 +1810,7 @@ func TestValidateHorizontalPodAutoscalerScaleToZeroDisabled(t *testing.T) {
nonZeroMinReplicasCases := prepareMinReplicasCases(t, 1) nonZeroMinReplicasCases := prepareMinReplicasCases(t, 1)
for _, successCase := range nonZeroMinReplicasCases { for _, successCase := range nonZeroMinReplicasCases {
successCase.Spec.MinReplicas = utilpointer.Int32Ptr(1) successCase.Spec.MinReplicas = utilpointer.Int32(1)
if errs := ValidateHorizontalPodAutoscaler(&successCase); len(errs) != 0 { if errs := ValidateHorizontalPodAutoscaler(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs) t.Errorf("expected success: %v", errs)
} }

View File

@ -44,7 +44,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
j.Parallelism = &parallelism j.Parallelism = &parallelism
j.BackoffLimit = &backoffLimit j.BackoffLimit = &backoffLimit
if c.Rand.Int31()%2 == 0 { if c.Rand.Int31()%2 == 0 {
j.ManualSelector = pointer.BoolPtr(true) j.ManualSelector = pointer.Bool(true)
} else { } else {
j.ManualSelector = nil j.ManualSelector = nil
} }
@ -55,7 +55,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
j.CompletionMode = &mode j.CompletionMode = &mode
// We're fuzzing the internal JobSpec type, not the v1 type, so we don't // We're fuzzing the internal JobSpec type, not the v1 type, so we don't
// need to fuzz the nil value. // need to fuzz the nil value.
j.Suspend = pointer.BoolPtr(c.RandBool()) j.Suspend = pointer.Bool(c.RandBool())
}, },
func(sj *batch.CronJobSpec, c fuzz.Continue) { func(sj *batch.CronJobSpec, c fuzz.Continue) {
c.FuzzNoCustom(sj) c.FuzzNoCustom(sj)

View File

@ -31,14 +31,14 @@ func SetDefaults_Job(obj *batchv1.Job) {
// For a non-parallel job, you can leave both `.spec.completions` and // For a non-parallel job, you can leave both `.spec.completions` and
// `.spec.parallelism` unset. When both are unset, both are defaulted to 1. // `.spec.parallelism` unset. When both are unset, both are defaulted to 1.
if obj.Spec.Completions == nil && obj.Spec.Parallelism == nil { if obj.Spec.Completions == nil && obj.Spec.Parallelism == nil {
obj.Spec.Completions = utilpointer.Int32Ptr(1) obj.Spec.Completions = utilpointer.Int32(1)
obj.Spec.Parallelism = utilpointer.Int32Ptr(1) obj.Spec.Parallelism = utilpointer.Int32(1)
} }
if obj.Spec.Parallelism == nil { if obj.Spec.Parallelism == nil {
obj.Spec.Parallelism = utilpointer.Int32Ptr(1) obj.Spec.Parallelism = utilpointer.Int32(1)
} }
if obj.Spec.BackoffLimit == nil { if obj.Spec.BackoffLimit == nil {
obj.Spec.BackoffLimit = utilpointer.Int32Ptr(6) obj.Spec.BackoffLimit = utilpointer.Int32(6)
} }
labels := obj.Spec.Template.Labels labels := obj.Spec.Template.Labels
if labels != nil && len(obj.Labels) == 0 { if labels != nil && len(obj.Labels) == 0 {
@ -49,7 +49,7 @@ func SetDefaults_Job(obj *batchv1.Job) {
obj.Spec.CompletionMode = &mode obj.Spec.CompletionMode = &mode
} }
if obj.Spec.Suspend == nil { if obj.Spec.Suspend == nil {
obj.Spec.Suspend = utilpointer.BoolPtr(false) obj.Spec.Suspend = utilpointer.Bool(false)
} }
if obj.Spec.PodFailurePolicy != nil { if obj.Spec.PodFailurePolicy != nil {
for _, rule := range obj.Spec.PodFailurePolicy.Rules { for _, rule := range obj.Spec.PodFailurePolicy.Rules {
@ -69,12 +69,12 @@ func SetDefaults_CronJob(obj *batchv1.CronJob) {
obj.Spec.ConcurrencyPolicy = batchv1.AllowConcurrent obj.Spec.ConcurrencyPolicy = batchv1.AllowConcurrent
} }
if obj.Spec.Suspend == nil { if obj.Spec.Suspend == nil {
obj.Spec.Suspend = utilpointer.BoolPtr(false) obj.Spec.Suspend = utilpointer.Bool(false)
} }
if obj.Spec.SuccessfulJobsHistoryLimit == nil { if obj.Spec.SuccessfulJobsHistoryLimit == nil {
obj.Spec.SuccessfulJobsHistoryLimit = utilpointer.Int32Ptr(3) obj.Spec.SuccessfulJobsHistoryLimit = utilpointer.Int32(3)
} }
if obj.Spec.FailedJobsHistoryLimit == nil { if obj.Spec.FailedJobsHistoryLimit == nil {
obj.Spec.FailedJobsHistoryLimit = utilpointer.Int32Ptr(1) obj.Spec.FailedJobsHistoryLimit = utilpointer.Int32(1)
} }
} }

View File

@ -85,11 +85,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
PodFailurePolicy: &batchv1.PodFailurePolicy{ PodFailurePolicy: &batchv1.PodFailurePolicy{
Rules: []batchv1.PodFailurePolicyRule{ Rules: []batchv1.PodFailurePolicyRule{
{ {
@ -141,11 +141,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -160,11 +160,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -172,7 +172,7 @@ func TestSetDefaultJob(t *testing.T) {
"suspend set, everything else is defaulted": { "suspend set, everything else is defaulted": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -180,11 +180,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -202,18 +202,18 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
}, },
"WQ: Parallelism explicitly 0 and completions unset -> BackoffLimit is defaulted": { "WQ: Parallelism explicitly 0 and completions unset -> BackoffLimit is defaulted": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Parallelism: pointer.Int32Ptr(0), Parallelism: pointer.Int32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -221,10 +221,10 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Parallelism: pointer.Int32Ptr(0), Parallelism: pointer.Int32(0),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -232,7 +232,7 @@ func TestSetDefaultJob(t *testing.T) {
"WQ: Parallelism explicitly 2 and completions unset -> BackoffLimit is defaulted": { "WQ: Parallelism explicitly 2 and completions unset -> BackoffLimit is defaulted": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Parallelism: pointer.Int32Ptr(2), Parallelism: pointer.Int32(2),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -240,10 +240,10 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Parallelism: pointer.Int32Ptr(2), Parallelism: pointer.Int32(2),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -251,7 +251,7 @@ func TestSetDefaultJob(t *testing.T) {
"Completions explicitly 2 and others unset -> parallelism and BackoffLimit are defaulted": { "Completions explicitly 2 and others unset -> parallelism and BackoffLimit are defaulted": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(2), Completions: pointer.Int32(2),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -259,11 +259,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(2), Completions: pointer.Int32(2),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(6), BackoffLimit: pointer.Int32(6),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -271,7 +271,7 @@ func TestSetDefaultJob(t *testing.T) {
"BackoffLimit explicitly 5 and others unset -> parallelism and completions are defaulted": { "BackoffLimit explicitly 5 and others unset -> parallelism and completions are defaulted": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
BackoffLimit: pointer.Int32Ptr(5), BackoffLimit: pointer.Int32(5),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -279,11 +279,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(1), Completions: pointer.Int32(1),
Parallelism: pointer.Int32Ptr(1), Parallelism: pointer.Int32(1),
BackoffLimit: pointer.Int32Ptr(5), BackoffLimit: pointer.Int32(5),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -291,11 +291,11 @@ func TestSetDefaultJob(t *testing.T) {
"All set -> no change": { "All set -> no change": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(8), Completions: pointer.Int32(8),
Parallelism: pointer.Int32Ptr(9), Parallelism: pointer.Int32(9),
BackoffLimit: pointer.Int32Ptr(10), BackoffLimit: pointer.Int32(10),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -303,11 +303,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(8), Completions: pointer.Int32(8),
Parallelism: pointer.Int32Ptr(9), Parallelism: pointer.Int32(9),
BackoffLimit: pointer.Int32Ptr(10), BackoffLimit: pointer.Int32(10),
CompletionMode: completionModePtr(batchv1.NonIndexedCompletion), CompletionMode: completionModePtr(batchv1.NonIndexedCompletion),
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -318,11 +318,11 @@ func TestSetDefaultJob(t *testing.T) {
"All set, flipped -> no change": { "All set, flipped -> no change": {
original: &batchv1.Job{ original: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(11), Completions: pointer.Int32(11),
Parallelism: pointer.Int32Ptr(10), Parallelism: pointer.Int32(10),
BackoffLimit: pointer.Int32Ptr(9), BackoffLimit: pointer.Int32(9),
CompletionMode: completionModePtr(batchv1.IndexedCompletion), CompletionMode: completionModePtr(batchv1.IndexedCompletion),
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels}, ObjectMeta: metav1.ObjectMeta{Labels: defaultLabels},
}, },
@ -330,11 +330,11 @@ func TestSetDefaultJob(t *testing.T) {
}, },
expected: &batchv1.Job{ expected: &batchv1.Job{
Spec: batchv1.JobSpec{ Spec: batchv1.JobSpec{
Completions: pointer.Int32Ptr(11), Completions: pointer.Int32(11),
Parallelism: pointer.Int32Ptr(10), Parallelism: pointer.Int32(10),
BackoffLimit: pointer.Int32Ptr(9), BackoffLimit: pointer.Int32(9),
CompletionMode: completionModePtr(batchv1.IndexedCompletion), CompletionMode: completionModePtr(batchv1.IndexedCompletion),
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
}, },
}, },
expectLabels: true, expectLabels: true,
@ -416,9 +416,9 @@ func TestSetDefaultCronJob(t *testing.T) {
expected: &batchv1.CronJob{ expected: &batchv1.CronJob{
Spec: batchv1.CronJobSpec{ Spec: batchv1.CronJobSpec{
ConcurrencyPolicy: batchv1.AllowConcurrent, ConcurrencyPolicy: batchv1.AllowConcurrent,
Suspend: pointer.BoolPtr(false), Suspend: pointer.Bool(false),
SuccessfulJobsHistoryLimit: pointer.Int32Ptr(3), SuccessfulJobsHistoryLimit: pointer.Int32(3),
FailedJobsHistoryLimit: pointer.Int32Ptr(1), FailedJobsHistoryLimit: pointer.Int32(1),
}, },
}, },
}, },
@ -426,17 +426,17 @@ func TestSetDefaultCronJob(t *testing.T) {
original: &batchv1.CronJob{ original: &batchv1.CronJob{
Spec: batchv1.CronJobSpec{ Spec: batchv1.CronJobSpec{
ConcurrencyPolicy: batchv1.ForbidConcurrent, ConcurrencyPolicy: batchv1.ForbidConcurrent,
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
SuccessfulJobsHistoryLimit: pointer.Int32Ptr(5), SuccessfulJobsHistoryLimit: pointer.Int32(5),
FailedJobsHistoryLimit: pointer.Int32Ptr(5), FailedJobsHistoryLimit: pointer.Int32(5),
}, },
}, },
expected: &batchv1.CronJob{ expected: &batchv1.CronJob{
Spec: batchv1.CronJobSpec{ Spec: batchv1.CronJobSpec{
ConcurrencyPolicy: batchv1.ForbidConcurrent, ConcurrencyPolicy: batchv1.ForbidConcurrent,
Suspend: pointer.BoolPtr(true), Suspend: pointer.Bool(true),
SuccessfulJobsHistoryLimit: pointer.Int32Ptr(5), SuccessfulJobsHistoryLimit: pointer.Int32(5),
FailedJobsHistoryLimit: pointer.Int32Ptr(5), FailedJobsHistoryLimit: pointer.Int32(5),
}, },
}, },
}, },

View File

@ -41,8 +41,8 @@ func TestSetDefaultCronJob(t *testing.T) {
Spec: batchv1beta1.CronJobSpec{ Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.AllowConcurrent, ConcurrencyPolicy: batchv1beta1.AllowConcurrent,
Suspend: newBool(false), Suspend: newBool(false),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(3), SuccessfulJobsHistoryLimit: utilpointer.Int32(3),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(1), FailedJobsHistoryLimit: utilpointer.Int32(1),
}, },
}, },
}, },
@ -51,16 +51,16 @@ func TestSetDefaultCronJob(t *testing.T) {
Spec: batchv1beta1.CronJobSpec{ Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.ForbidConcurrent, ConcurrencyPolicy: batchv1beta1.ForbidConcurrent,
Suspend: newBool(true), Suspend: newBool(true),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(5), SuccessfulJobsHistoryLimit: utilpointer.Int32(5),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(5), FailedJobsHistoryLimit: utilpointer.Int32(5),
}, },
}, },
expected: &batchv1beta1.CronJob{ expected: &batchv1beta1.CronJob{
Spec: batchv1beta1.CronJobSpec{ Spec: batchv1beta1.CronJobSpec{
ConcurrencyPolicy: batchv1beta1.ForbidConcurrent, ConcurrencyPolicy: batchv1beta1.ForbidConcurrent,
Suspend: newBool(true), Suspend: newBool(true),
SuccessfulJobsHistoryLimit: utilpointer.Int32Ptr(5), SuccessfulJobsHistoryLimit: utilpointer.Int32(5),
FailedJobsHistoryLimit: utilpointer.Int32Ptr(5), FailedJobsHistoryLimit: utilpointer.Int32(5),
}, },
}, },
}, },

View File

@ -168,7 +168,7 @@ func TestValidateJob(t *testing.T) {
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validManualSelector, Selector: validManualSelector,
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: validPodTemplateSpecForManual, Template: validPodTemplateSpecForManual,
}, },
}, },
@ -211,8 +211,8 @@ func TestValidateJob(t *testing.T) {
Selector: validGeneratedSelector, Selector: validGeneratedSelector,
Template: validPodTemplateSpecForGenerated, Template: validPodTemplateSpecForGenerated,
CompletionMode: completionModePtr(batch.IndexedCompletion), CompletionMode: completionModePtr(batch.IndexedCompletion),
Completions: pointer.Int32Ptr(2), Completions: pointer.Int32(2),
Parallelism: pointer.Int32Ptr(100000), Parallelism: pointer.Int32(100000),
}, },
}, },
}, },
@ -709,7 +709,7 @@ func TestValidateJob(t *testing.T) {
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validManualSelector, Selector: validManualSelector,
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"y": "z"}, Labels: map[string]string{"y": "z"},
@ -730,7 +730,7 @@ func TestValidateJob(t *testing.T) {
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validManualSelector, Selector: validManualSelector,
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"controller-uid": "4d5e6f"}, Labels: map[string]string{"controller-uid": "4d5e6f"},
@ -751,7 +751,7 @@ func TestValidateJob(t *testing.T) {
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validManualSelector, Selector: validManualSelector,
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: validManualSelector.MatchLabels, Labels: validManualSelector.MatchLabels,
@ -772,7 +772,7 @@ func TestValidateJob(t *testing.T) {
}, },
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validManualSelector, Selector: validManualSelector,
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: api.PodTemplateSpec{ Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: validManualSelector.MatchLabels, Labels: validManualSelector.MatchLabels,
@ -819,8 +819,8 @@ func TestValidateJob(t *testing.T) {
Selector: validGeneratedSelector, Selector: validGeneratedSelector,
Template: validPodTemplateSpecForGenerated, Template: validPodTemplateSpecForGenerated,
CompletionMode: completionModePtr(batch.IndexedCompletion), CompletionMode: completionModePtr(batch.IndexedCompletion),
Completions: pointer.Int32Ptr(2), Completions: pointer.Int32(2),
Parallelism: pointer.Int32Ptr(100001), Parallelism: pointer.Int32(100001),
}, },
}, },
"metadata.annotations[batch.kubernetes.io/job-tracking]: cannot add this annotation": { "metadata.annotations[batch.kubernetes.io/job-tracking]: cannot add this annotation": {
@ -920,16 +920,16 @@ func TestValidateJobUpdate(t *testing.T) {
Spec: batch.JobSpec{ Spec: batch.JobSpec{
Selector: validGeneratedSelector, Selector: validGeneratedSelector,
Template: validPodTemplateSpecForGenerated, Template: validPodTemplateSpecForGenerated,
Parallelism: pointer.Int32Ptr(5), Parallelism: pointer.Int32(5),
ActiveDeadlineSeconds: pointer.Int64Ptr(2), ActiveDeadlineSeconds: pointer.Int64(2),
TTLSecondsAfterFinished: pointer.Int32Ptr(1), TTLSecondsAfterFinished: pointer.Int32(1),
}, },
}, },
update: func(job *batch.Job) { update: func(job *batch.Job) {
job.Spec.Parallelism = pointer.Int32Ptr(2) job.Spec.Parallelism = pointer.Int32(2)
job.Spec.ActiveDeadlineSeconds = pointer.Int64Ptr(3) job.Spec.ActiveDeadlineSeconds = pointer.Int64(3)
job.Spec.TTLSecondsAfterFinished = pointer.Int32Ptr(2) job.Spec.TTLSecondsAfterFinished = pointer.Int32(2)
job.Spec.ManualSelector = pointer.BoolPtr(true) job.Spec.ManualSelector = pointer.Bool(true)
}, },
}, },
"immutable completions for non-indexed jobs": { "immutable completions for non-indexed jobs": {
@ -957,7 +957,7 @@ func TestValidateJobUpdate(t *testing.T) {
}, },
}, },
update: func(job *batch.Job) { update: func(job *batch.Job) {
job.Spec.Completions = pointer.Int32Ptr(1) job.Spec.Completions = pointer.Int32(1)
}, },
err: &field.Error{ err: &field.Error{
Type: field.ErrorTypeInvalid, Type: field.ErrorTypeInvalid,
@ -1097,7 +1097,7 @@ func TestValidateJobUpdate(t *testing.T) {
Selector: validGeneratedSelector, Selector: validGeneratedSelector,
Template: validPodTemplateSpecForGenerated, Template: validPodTemplateSpecForGenerated,
CompletionMode: completionModePtr(batch.IndexedCompletion), CompletionMode: completionModePtr(batch.IndexedCompletion),
Completions: pointer.Int32Ptr(2), Completions: pointer.Int32(2),
}, },
}, },
update: func(job *batch.Job) { update: func(job *batch.Job) {
@ -2025,7 +2025,7 @@ func TestValidateCronJob(t *testing.T) {
ConcurrencyPolicy: batch.AllowConcurrent, ConcurrencyPolicy: batch.AllowConcurrent,
JobTemplate: batch.JobTemplateSpec{ JobTemplate: batch.JobTemplateSpec{
Spec: batch.JobSpec{ Spec: batch.JobSpec{
ManualSelector: pointer.BoolPtr(true), ManualSelector: pointer.Bool(true),
Template: validPodTemplateSpec, Template: validPodTemplateSpec,
}, },
}, },

View File

@ -524,7 +524,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
ss.SessionAffinityConfig = nil ss.SessionAffinityConfig = nil
} }
if ss.AllocateLoadBalancerNodePorts == nil { if ss.AllocateLoadBalancerNodePorts == nil {
ss.AllocateLoadBalancerNodePorts = utilpointer.BoolPtr(true) ss.AllocateLoadBalancerNodePorts = utilpointer.Bool(true)
} }
}, },
func(s *core.NodeStatus, c fuzz.Continue) { func(s *core.NodeStatus, c fuzz.Continue) {

View File

@ -247,7 +247,7 @@ func TestReplicationControllerConversion(t *testing.T) {
Namespace: "namespace", Namespace: "namespace",
}, },
Spec: v1.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
Replicas: utilpointer.Int32Ptr(1), Replicas: utilpointer.Int32(1),
MinReadySeconds: 32, MinReadySeconds: 32,
Selector: map[string]string{"foo": "bar", "bar": "foo"}, Selector: map[string]string{"foo": "bar", "bar": "foo"},
Template: &v1.PodTemplateSpec{ Template: &v1.PodTemplateSpec{

View File

@ -137,7 +137,7 @@ func SetDefaults_Service(obj *v1.Service) {
if obj.Spec.Type == v1.ServiceTypeLoadBalancer { if obj.Spec.Type == v1.ServiceTypeLoadBalancer {
if obj.Spec.AllocateLoadBalancerNodePorts == nil { if obj.Spec.AllocateLoadBalancerNodePorts == nil {
obj.Spec.AllocateLoadBalancerNodePorts = pointer.BoolPtr(true) obj.Spec.AllocateLoadBalancerNodePorts = pointer.Bool(true)
} }
} }
} }

View File

@ -582,7 +582,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
{ {
rc: v1.ReplicationController{ rc: v1.ReplicationController{
Spec: v1.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
Replicas: utilpointer.Int32Ptr(0), Replicas: utilpointer.Int32(0),
Template: &v1.PodTemplateSpec{ Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -597,7 +597,7 @@ func TestSetDefaultReplicationControllerReplicas(t *testing.T) {
{ {
rc: v1.ReplicationController{ rc: v1.ReplicationController{
Spec: v1.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: &v1.PodTemplateSpec{ Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -1730,7 +1730,7 @@ func TestDefaultRequestIsNotSetForReplicationController(t *testing.T) {
} }
rc := &v1.ReplicationController{ rc := &v1.ReplicationController{
Spec: v1.ReplicationControllerSpec{ Spec: v1.ReplicationControllerSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: &v1.PodTemplateSpec{ Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{

View File

@ -40,13 +40,13 @@ func TestSetDefaultEndpointPort(t *testing.T) {
}{ }{
"should set appropriate defaults": { "should set appropriate defaults": {
original: &discovery.EndpointSlice{Ports: []discovery.EndpointPort{{ original: &discovery.EndpointSlice{Ports: []discovery.EndpointPort{{
Port: utilpointer.Int32Ptr(80), Port: utilpointer.Int32(80),
}}}, }}},
expected: &discovery.EndpointSlice{ expected: &discovery.EndpointSlice{
Ports: []discovery.EndpointPort{{ Ports: []discovery.EndpointPort{{
Name: &emptyStr, Name: &emptyStr,
Protocol: &protoTCP, Protocol: &protoTCP,
Port: utilpointer.Int32Ptr(80), Port: utilpointer.Int32(80),
}}, }},
}, },
}, },

View File

@ -40,13 +40,13 @@ func TestSetDefaultEndpointPort(t *testing.T) {
}{ }{
"should set appropriate defaults": { "should set appropriate defaults": {
original: &discovery.EndpointSlice{Ports: []discovery.EndpointPort{{ original: &discovery.EndpointSlice{Ports: []discovery.EndpointPort{{
Port: utilpointer.Int32Ptr(80), Port: utilpointer.Int32(80),
}}}, }}},
expected: &discovery.EndpointSlice{ expected: &discovery.EndpointSlice{
Ports: []discovery.EndpointPort{{ Ports: []discovery.EndpointPort{{
Name: &emptyStr, Name: &emptyStr,
Protocol: &protoTCP, Protocol: &protoTCP,
Port: utilpointer.Int32Ptr(80), Port: utilpointer.Int32(80),
}}, }},
}, },
}, },

View File

@ -82,7 +82,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{ UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType, Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -95,7 +95,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
}, },
Spec: extensionsv1beta1.DaemonSetSpec{ Spec: extensionsv1beta1.DaemonSetSpec{
Template: defaultTemplate, Template: defaultTemplate,
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
expected: &extensionsv1beta1.DaemonSet{ expected: &extensionsv1beta1.DaemonSet{
@ -112,7 +112,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{ UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType, Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(1), RevisionHistoryLimit: utilpointer.Int32(1),
}, },
}, },
}, },
@ -124,7 +124,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{ UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType, Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -138,7 +138,7 @@ func TestSetDefaultDaemonSetSpec(t *testing.T) {
UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{ UpdateStrategy: extensionsv1beta1.DaemonSetUpdateStrategy{
Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType, Type: extensionsv1beta1.OnDeleteDaemonSetStrategyType,
}, },
RevisionHistoryLimit: utilpointer.Int32Ptr(10), RevisionHistoryLimit: utilpointer.Int32(10),
}, },
}, },
}, },
@ -180,7 +180,7 @@ func TestSetDefaultDeployment(t *testing.T) {
original: &extensionsv1beta1.Deployment{}, original: &extensionsv1beta1.Deployment{},
expected: &extensionsv1beta1.Deployment{ expected: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(1), Replicas: utilpointer.Int32(1),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType, Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{ RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
@ -189,15 +189,15 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
}, },
Template: defaultTemplate, Template: defaultTemplate,
ProgressDeadlineSeconds: utilpointer.Int32Ptr(math.MaxInt32), ProgressDeadlineSeconds: utilpointer.Int32(math.MaxInt32),
RevisionHistoryLimit: utilpointer.Int32Ptr(math.MaxInt32), RevisionHistoryLimit: utilpointer.Int32(math.MaxInt32),
}, },
}, },
}, },
{ {
original: &extensionsv1beta1.Deployment{ original: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{ RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
MaxSurge: &differentIntOrString, MaxSurge: &differentIntOrString,
@ -207,7 +207,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &extensionsv1beta1.Deployment{ expected: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType, Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{ RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
@ -216,15 +216,15 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
}, },
Template: defaultTemplate, Template: defaultTemplate,
ProgressDeadlineSeconds: utilpointer.Int32Ptr(math.MaxInt32), ProgressDeadlineSeconds: utilpointer.Int32(math.MaxInt32),
RevisionHistoryLimit: utilpointer.Int32Ptr(math.MaxInt32), RevisionHistoryLimit: utilpointer.Int32(math.MaxInt32),
}, },
}, },
}, },
{ {
original: &extensionsv1beta1.Deployment{ original: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType, Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: nil, RollingUpdate: nil,
@ -233,7 +233,7 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &extensionsv1beta1.Deployment{ expected: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType, Type: extensionsv1beta1.RollingUpdateDeploymentStrategyType,
RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{ RollingUpdate: &extensionsv1beta1.RollingUpdateDeployment{
@ -242,15 +242,15 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
}, },
Template: defaultTemplate, Template: defaultTemplate,
ProgressDeadlineSeconds: utilpointer.Int32Ptr(math.MaxInt32), ProgressDeadlineSeconds: utilpointer.Int32(math.MaxInt32),
RevisionHistoryLimit: utilpointer.Int32Ptr(math.MaxInt32), RevisionHistoryLimit: utilpointer.Int32(math.MaxInt32),
}, },
}, },
}, },
{ {
original: &extensionsv1beta1.Deployment{ original: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RecreateDeploymentStrategyType, Type: extensionsv1beta1.RecreateDeploymentStrategyType,
}, },
@ -258,35 +258,35 @@ func TestSetDefaultDeployment(t *testing.T) {
}, },
expected: &extensionsv1beta1.Deployment{ expected: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RecreateDeploymentStrategyType, Type: extensionsv1beta1.RecreateDeploymentStrategyType,
}, },
Template: defaultTemplate, Template: defaultTemplate,
ProgressDeadlineSeconds: utilpointer.Int32Ptr(math.MaxInt32), ProgressDeadlineSeconds: utilpointer.Int32(math.MaxInt32),
RevisionHistoryLimit: utilpointer.Int32Ptr(math.MaxInt32), RevisionHistoryLimit: utilpointer.Int32(math.MaxInt32),
}, },
}, },
}, },
{ {
original: &extensionsv1beta1.Deployment{ original: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RecreateDeploymentStrategyType, Type: extensionsv1beta1.RecreateDeploymentStrategyType,
}, },
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
}, },
}, },
expected: &extensionsv1beta1.Deployment{ expected: &extensionsv1beta1.Deployment{
Spec: extensionsv1beta1.DeploymentSpec{ Spec: extensionsv1beta1.DeploymentSpec{
Replicas: utilpointer.Int32Ptr(5), Replicas: utilpointer.Int32(5),
Strategy: extensionsv1beta1.DeploymentStrategy{ Strategy: extensionsv1beta1.DeploymentStrategy{
Type: extensionsv1beta1.RecreateDeploymentStrategyType, Type: extensionsv1beta1.RecreateDeploymentStrategyType,
}, },
Template: defaultTemplate, Template: defaultTemplate,
ProgressDeadlineSeconds: utilpointer.Int32Ptr(30), ProgressDeadlineSeconds: utilpointer.Int32(30),
RevisionHistoryLimit: utilpointer.Int32Ptr(math.MaxInt32), RevisionHistoryLimit: utilpointer.Int32(math.MaxInt32),
}, },
}, },
}, },
@ -442,7 +442,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: extensionsv1beta1.ReplicaSet{ rs: extensionsv1beta1.ReplicaSet{
Spec: extensionsv1beta1.ReplicaSetSpec{ Spec: extensionsv1beta1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(0), Replicas: utilpointer.Int32(0),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -457,7 +457,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{ {
rs: extensionsv1beta1.ReplicaSet{ rs: extensionsv1beta1.ReplicaSet{
Spec: extensionsv1beta1.ReplicaSetSpec{ Spec: extensionsv1beta1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
@ -500,7 +500,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
} }
rs := &extensionsv1beta1.ReplicaSet{ rs := &extensionsv1beta1.ReplicaSet{
Spec: extensionsv1beta1.ReplicaSetSpec{ Spec: extensionsv1beta1.ReplicaSetSpec{
Replicas: utilpointer.Int32Ptr(3), Replicas: utilpointer.Int32(3),
Template: v1.PodTemplateSpec{ Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{

View File

@ -227,12 +227,12 @@ func TestValidateScheduling(t *testing.T) {
Key: "valid", Key: "valid",
Operator: core.TolerationOpExists, Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoExecute, Effect: core.TaintEffectNoExecute,
TolerationSeconds: utilpointer.Int64Ptr(5), TolerationSeconds: utilpointer.Int64(5),
}, { }, {
Key: "valid", Key: "valid",
Operator: core.TolerationOpExists, Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoExecute, Effect: core.TaintEffectNoExecute,
TolerationSeconds: utilpointer.Int64Ptr(10), TolerationSeconds: utilpointer.Int64(10),
}}, }},
}, },
expectErrs: 1, expectErrs: 1,

View File

@ -1121,7 +1121,7 @@ func TestCSINodeValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver", Name: "io.kubernetes.storage.csi.driver",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(0)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(0)},
}, },
}, },
}, },
@ -1135,7 +1135,7 @@ func TestCSINodeValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver", Name: "io.kubernetes.storage.csi.driver",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(1)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(1)},
}, },
}, },
}, },
@ -1384,7 +1384,7 @@ func TestCSINodeValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver", Name: "io.kubernetes.storage.csi.driver",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(-1)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(-1)},
}, },
}, },
}, },
@ -1431,7 +1431,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
}, },
}, },
@ -1452,7 +1452,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
}, },
}, },
@ -1484,13 +1484,13 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
{ {
Name: "io.kubernetes.storage.csi.driver-3", Name: "io.kubernetes.storage.csi.driver-3",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(30)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(30)},
}, },
}, },
}, },
@ -1509,7 +1509,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.new-driver", Name: "io.kubernetes.storage.csi.new-driver",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(30)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(30)},
}, },
}, },
}, },
@ -1537,7 +1537,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
}, },
}, },
@ -1556,7 +1556,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone2"}, TopologyKeys: []string{"company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
}, },
}, },
@ -1570,13 +1570,13 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-1", Name: "io.kubernetes.storage.csi.driver-1",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(10)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(10)},
}, },
{ {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(20)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(20)},
}, },
}, },
}, },
@ -1595,7 +1595,7 @@ func TestCSINodeUpdateValidation(t *testing.T) {
Name: "io.kubernetes.storage.csi.driver-2", Name: "io.kubernetes.storage.csi.driver-2",
NodeID: nodeID, NodeID: nodeID,
TopologyKeys: []string{"company.com/zone1", "company.com/zone2"}, TopologyKeys: []string{"company.com/zone1", "company.com/zone2"},
Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32Ptr(21)}, Allocatable: &storage.VolumeNodeResources{Count: utilpointer.Int32(21)},
}, },
}, },
}, },
@ -2217,7 +2217,7 @@ func TestCSIServiceAccountToken(t *testing.T) {
csiDriver: &storage.CSIDriver{ csiDriver: &storage.CSIDriver{
ObjectMeta: metav1.ObjectMeta{Name: driverName}, ObjectMeta: metav1.ObjectMeta{Name: driverName},
Spec: storage.CSIDriverSpec{ Spec: storage.CSIDriverSpec{
TokenRequests: []storage.TokenRequest{{Audience: gcp, ExpirationSeconds: utilpointer.Int64Ptr(10)}}, TokenRequests: []storage.TokenRequest{{Audience: gcp, ExpirationSeconds: utilpointer.Int64(10)}},
RequiresRepublish: &notRequiresRepublish, RequiresRepublish: &notRequiresRepublish,
}, },
}, },
@ -2228,7 +2228,7 @@ func TestCSIServiceAccountToken(t *testing.T) {
csiDriver: &storage.CSIDriver{ csiDriver: &storage.CSIDriver{
ObjectMeta: metav1.ObjectMeta{Name: driverName}, ObjectMeta: metav1.ObjectMeta{Name: driverName},
Spec: storage.CSIDriverSpec{ Spec: storage.CSIDriverSpec{
TokenRequests: []storage.TokenRequest{{Audience: gcp, ExpirationSeconds: utilpointer.Int64Ptr(1<<32 + 1)}}, TokenRequests: []storage.TokenRequest{{Audience: gcp, ExpirationSeconds: utilpointer.Int64(1<<32 + 1)}},
RequiresRepublish: &notRequiresRepublish, RequiresRepublish: &notRequiresRepublish,
}, },
}, },