Skip to content

Commit 1958edd

Browse files
authored
don't assign default zero value to maxReplicas (#161)
1 parent 7c483d1 commit 1958edd

6 files changed

Lines changed: 6 additions & 21 deletions

File tree

api/v1alpha1/function_webhook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ func (r *Function) Default() {
5151
r.Spec.Replicas = &zeroVal
5252
}
5353

54-
if r.Spec.MaxReplicas == nil {
55-
zeroVal := int32(0)
56-
r.Spec.MaxReplicas = &zeroVal
57-
}
58-
5954
if r.Spec.AutoAck == nil {
6055
trueVal := true
6156
r.Spec.AutoAck = &trueVal

api/v1alpha1/sink_webhook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ func (r *Sink) Default() {
5151
r.Spec.Replicas = &zeroVal
5252
}
5353

54-
if r.Spec.MaxReplicas == nil {
55-
zeroVal := int32(0)
56-
r.Spec.MaxReplicas = &zeroVal
57-
}
58-
5954
if r.Spec.AutoAck == nil {
6055
trueVal := true
6156
r.Spec.AutoAck = &trueVal

api/v1alpha1/source_webhook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ func (r *Source) Default() {
5151
r.Spec.Replicas = &zeroVal
5252
}
5353

54-
if r.Spec.MaxReplicas == nil {
55-
zeroVal := int32(0)
56-
r.Spec.MaxReplicas = &zeroVal
57-
}
58-
5954
//if r.Spec.AutoAck == nil {
6055
// trueVal := true
6156
// r.Spec.AutoAck = &trueVal

controllers/function.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (r *FunctionReconciler) ApplyFunctionService(ctx context.Context, req ctrl.
165165

166166
func (r *FunctionReconciler) ObserveFunctionHPA(ctx context.Context, req ctrl.Request,
167167
function *v1alpha1.Function) error {
168-
if *function.Spec.MaxReplicas == 0 {
168+
if function.Spec.MaxReplicas == nil {
169169
// HPA not enabled, skip further action
170170
return nil
171171
}
@@ -202,7 +202,7 @@ func (r *FunctionReconciler) ObserveFunctionHPA(ctx context.Context, req ctrl.Re
202202

203203
func (r *FunctionReconciler) ApplyFunctionHPA(ctx context.Context, req ctrl.Request,
204204
function *v1alpha1.Function) error {
205-
if *function.Spec.MaxReplicas == 0 {
205+
if function.Spec.MaxReplicas == nil {
206206
// HPA not enabled, skip further action
207207
return nil
208208
}

controllers/sink.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (r *SinkReconciler) ApplySinkService(ctx context.Context, req ctrl.Request,
161161
}
162162

163163
func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, sink *v1alpha1.Sink) error {
164-
if *sink.Spec.MaxReplicas == 0 {
164+
if sink.Spec.MaxReplicas == nil {
165165
// HPA not enabled, skip further action
166166
return nil
167167
}
@@ -197,7 +197,7 @@ func (r *SinkReconciler) ObserveSinkHPA(ctx context.Context, req ctrl.Request, s
197197
}
198198

199199
func (r *SinkReconciler) ApplySinkHPA(ctx context.Context, req ctrl.Request, sink *v1alpha1.Sink) error {
200-
if *sink.Spec.MaxReplicas == 0 {
200+
if sink.Spec.MaxReplicas == nil {
201201
// HPA not enabled, skip further action
202202
return nil
203203
}

controllers/source.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (r *SourceReconciler) ApplySourceService(ctx context.Context, req ctrl.Requ
163163
}
164164

165165
func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Request, source *v1alpha1.Source) error {
166-
if *source.Spec.MaxReplicas == 0 {
166+
if source.Spec.MaxReplicas == nil {
167167
// HPA not enabled, skip further action
168168
return nil
169169
}
@@ -199,7 +199,7 @@ func (r *SourceReconciler) ObserveSourceHPA(ctx context.Context, req ctrl.Reques
199199
}
200200

201201
func (r *SourceReconciler) ApplySourceHPA(ctx context.Context, req ctrl.Request, source *v1alpha1.Source) error {
202-
if *source.Spec.MaxReplicas == 0 {
202+
if source.Spec.MaxReplicas == nil {
203203
// HPA not enabled, skip further action
204204
return nil
205205
}

0 commit comments

Comments
 (0)