Skip to content

Commit

Permalink
use k8s.io/utils/ptr instead of k8s.io/utils/pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed May 15, 2024
1 parent 04c6938 commit ee701cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmd/plugin/rpaasv2/cmd/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/tsuru/rpaas-operator/pkg/rpaas/client/autogenerated"
)
Expand Down Expand Up @@ -71,7 +71,7 @@ max replicas: 5
Schedules: []autogenerated.ScheduledWindow{
{MinReplicas: 1, Start: "00 08 * * 1-5", End: "00 20 * * 1-5"},
{MinReplicas: 5, Start: "00 20 * * 2", End: "00 01 * * 3"},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1", Timezone: pointer.String("America/Chile")},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1", Timezone: ptr.To("America/Chile")},
},
})
}),
Expand Down
40 changes: 20 additions & 20 deletions controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/tools/record"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand Down Expand Up @@ -1012,7 +1012,7 @@ func Test_reconcileHPA(t *testing.T) {
Kind: "Deployment",
Name: "my-instance",
},
MinReplicas: pointer.Int32(1),
MinReplicas: ptr.To(int32(1)),
MaxReplicas: 10,
Metrics: []autoscalingv2.MetricSpec{
{
Expand All @@ -1021,7 +1021,7 @@ func Test_reconcileHPA(t *testing.T) {
Name: "cpu",
Target: autoscalingv2.MetricTarget{
Type: autoscalingv2.UtilizationMetricType,
AverageUtilization: pointer.Int32(50),
AverageUtilization: ptr.To(int32(50)),
},
},
},
Expand All @@ -1032,9 +1032,9 @@ func Test_reconcileHPA(t *testing.T) {
},
instance: func(ri *v1alpha1.RpaasInstance) *v1alpha1.RpaasInstance {
ri.Spec.Autoscale = &v1alpha1.RpaasInstanceAutoscaleSpec{
MinReplicas: pointer.Int32(1),
MinReplicas: ptr.To(int32(1)),
MaxReplicas: 10,
TargetCPUUtilizationPercentage: pointer.Int32(50),
TargetCPUUtilizationPercentage: ptr.To(int32(50)),
}
return ri
},
Expand All @@ -1047,7 +1047,7 @@ func Test_reconcileHPA(t *testing.T) {
Kind: "Deployment",
Name: "my-instance",
},
MinReplicas: pointer.Int32(1),
MinReplicas: ptr.To(int32(1)),
MaxReplicas: 10,
Metrics: []autoscalingv2.MetricSpec{
{
Expand All @@ -1056,7 +1056,7 @@ func Test_reconcileHPA(t *testing.T) {
Name: "cpu",
Target: autoscalingv2.MetricTarget{
Type: autoscalingv2.UtilizationMetricType,
AverageUtilization: pointer.Int32(50),
AverageUtilization: ptr.To(int32(50)),
},
},
},
Expand Down Expand Up @@ -1230,9 +1230,9 @@ func Test_reconcileHPA(t *testing.T) {
Kind: "Deployment",
Name: "my-instance",
},
MinReplicaCount: pointer.Int32(2),
MaxReplicaCount: pointer.Int32(500),
PollingInterval: pointer.Int32(5),
MinReplicaCount: ptr.To(int32(2)),
MaxReplicaCount: ptr.To(int32(500)),
PollingInterval: ptr.To(int32(5)),
Advanced: &kedav1alpha1.AdvancedConfig{
HorizontalPodAutoscalerConfig: &kedav1alpha1.HorizontalPodAutoscalerConfig{
Name: "my-instance",
Expand All @@ -1259,9 +1259,9 @@ func Test_reconcileHPA(t *testing.T) {
expectedChanged: false,
instance: func(ri *v1alpha1.RpaasInstance) *v1alpha1.RpaasInstance {
ri.Spec.Autoscale = &v1alpha1.RpaasInstanceAutoscaleSpec{
MinReplicas: pointer.Int32(2),
MinReplicas: ptr.To(int32(2)),
MaxReplicas: 500,
TargetRequestsPerSecond: pointer.Int32(50),
TargetRequestsPerSecond: ptr.To(int32(50)),
KEDAOptions: &v1alpha1.AutoscaleKEDAOptions{
Enabled: true,
PrometheusServerAddress: "https://prometheus.example.com",
Expand All @@ -1270,15 +1270,15 @@ func Test_reconcileHPA(t *testing.T) {
Kind: "ClusterTriggerAuthentication",
Name: "prometheus-auth",
},
PollingInterval: pointer.Int32(5),
PollingInterval: ptr.To(int32(5)),
},
}
return ri
},
expectedScaledObject: func(so *kedav1alpha1.ScaledObject) *kedav1alpha1.ScaledObject {
so.Spec.MinReplicaCount = pointer.Int32(2)
so.Spec.MaxReplicaCount = pointer.Int32(500)
so.Spec.PollingInterval = pointer.Int32(5)
so.Spec.MinReplicaCount = ptr.To(int32(2))
so.Spec.MaxReplicaCount = ptr.To(int32(500))
so.Spec.PollingInterval = ptr.To(int32(5))
so.Spec.Triggers = []kedav1alpha1.ScaleTriggers{
{
Type: "prometheus",
Expand Down Expand Up @@ -1569,8 +1569,8 @@ func Test_reconcilePDB(t *testing.T) {
Namespace: "rpaasv2",
},
Spec: v1alpha1.RpaasInstanceSpec{
EnablePodDisruptionBudget: pointer.Bool(true),
Replicas: pointer.Int32(1),
EnablePodDisruptionBudget: ptr.To(true),
Replicas: ptr.To(int32(1)),
},
},
expectedChanged: true,
Expand Down Expand Up @@ -2229,8 +2229,8 @@ func TestReconcileRpaasInstance_reconcileTLSSessionResumption(t *testing.T) {
},
Spec: batchv1.CronJobSpec{
Schedule: "*/60 * * * *",
SuccessfulJobsHistoryLimit: pointer.Int32(1),
FailedJobsHistoryLimit: pointer.Int32(1),
SuccessfulJobsHistoryLimit: ptr.To(int32(1)),
FailedJobsHistoryLimit: ptr.To(int32(1)),
JobTemplate: batchv1.JobTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand Down

0 comments on commit ee701cd

Please sign in to comment.