From f9a9e97a4506661f874ea262566d2262caed10c1 Mon Sep 17 00:00:00 2001 From: hkepley Date: Tue, 6 Aug 2024 10:46:37 -0400 Subject: [PATCH] OCM-9974 | fix: Change options validations to allow 0 min replicas as well --- cmd/edit/machinepool/options.go | 8 ++++---- cmd/edit/machinepool/options_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/edit/machinepool/options.go b/cmd/edit/machinepool/options.go index ac78e7addb..fed842e73b 100644 --- a/cmd/edit/machinepool/options.go +++ b/cmd/edit/machinepool/options.go @@ -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") diff --git a/cmd/edit/machinepool/options_test.go b/cmd/edit/machinepool/options_test.go index 360acbbfab..b3a400185d 100644 --- a/cmd/edit/machinepool/options_test.go +++ b/cmd/edit/machinepool/options_test.go @@ -57,7 +57,7 @@ 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 @@ -65,7 +65,7 @@ var _ = Describe("Test edit machinepool options", func() { 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