Skip to content

Commit

Permalink
OCM-9974 | fix: Change options validations to allow 0 min replicas as…
Browse files Browse the repository at this point in the history
… well
  • Loading branch information
hunterkepley committed Aug 6, 2024
1 parent 55ad3b8 commit f9a9e97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/edit/machinepool/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func (m *EditMachinepoolOptions) Bind(args *EditMachinepoolUserOptions, argv []s
}

if m.args.autoscalingEnabled {
if m.args.minReplicas <= 0 {
return fmt.Errorf("Min replicas must be greater than zero when autoscaling is enabled")
if m.args.minReplicas < 0 {
return fmt.Errorf("Min replicas must be a number that is 0 or greater when autoscaling is enabled")
}
if m.args.maxReplicas <= 0 {
return fmt.Errorf("Max replicas must be greater than zero when autoscaling is enabled")
if m.args.maxReplicas < 0 {
return fmt.Errorf("Max replicas must be a number that is 0 or greater when autoscaling is enabled")
}
if m.args.minReplicas > m.args.maxReplicas {
return fmt.Errorf("Min replicas must be less than max replicas")
Expand Down
4 changes: 2 additions & 2 deletions cmd/edit/machinepool/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ var _ = Describe("Test edit machinepool options", func() {
args.autoscalingEnabled = true
args.machinepool = "test"
err := options.Bind(args, []string{})
Expect(err).To(MatchError("Min replicas must be greater than zero when autoscaling is enabled"))
Expect(err).To(MatchError("Min replicas must be a number that is 0 or greater when autoscaling is enabled"))
})
It("Test max replicas negative value (fail)", func() {
args.maxReplicas = -1
args.minReplicas = 1
args.autoscalingEnabled = true
args.machinepool = "test"
err := options.Bind(args, []string{})
Expect(err).To(MatchError("Max replicas must be greater than zero when autoscaling is enabled"))
Expect(err).To(MatchError("Max replicas must be a number that is 0 or greater when autoscaling is enabled"))
})
It("Test min replicas > max replicas (fail)", func() {
args.maxReplicas = 1
Expand Down

0 comments on commit f9a9e97

Please sign in to comment.