Skip to content

Commit

Permalink
OCM-7526 | fix: Display min/max in describe machinepool
Browse files Browse the repository at this point in the history
Signed-off-by: Maggie Chen <magchen@redhat.com>
  • Loading branch information
chenz4027 committed May 7, 2024
1 parent 4404292 commit a5553b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pkg/machinepool/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,19 @@ var _ = Describe("Output", Ordered, func() {
Expect(out).To(Equal(result))
})
It("nodepool output with autoscaling", func() {
nodePoolBuilder := *cmv1.NewNodePool().ID("test-mp").Autoscaling(cmv1.NewNodePoolAutoscaling().
ID("test-as").MinReplica(2).MaxReplica(8)).Replicas(4).
npAutoscaling := cmv1.NewNodePoolAutoscaling().ID("test-as").MinReplica(2).MaxReplica(8)
nodePoolBuilder := *cmv1.NewNodePool().ID("test-mp").Autoscaling(npAutoscaling).Replicas(4).
AvailabilityZone("test-az").Subnet("test-subnets").Version(cmv1.NewVersion().
ID("1")).AutoRepair(false).TuningConfigs("test-tc").Labels(labels).
Taints(taintsBuilder)
nodePool, err := nodePoolBuilder.Build()
Expect(err).ToNot(HaveOccurred())
labelsOutput := ocmOutput.PrintLabels(labels)
taintsOutput := ocmOutput.PrintTaints([]*cmv1.Taint{taint})
replicasOutput := ocmOutput.PrintNodePoolReplicas((*cmv1.NodePoolAutoscaling)(npAutoscaling), 4)

out := fmt.Sprintf(nodePoolOutputString,
"test-mp", "test-cluster", "Yes", "2-8", "", "", labelsOutput, "", taintsOutput, "test-az",
"test-mp", "test-cluster", "Yes", replicasOutput, "", "", labelsOutput, "", taintsOutput, "test-az",
"test-subnets", "1", "No", "test-tc", "", "", "")

result := nodePoolOutput("test-cluster", nodePool)
Expand Down
4 changes: 3 additions & 1 deletion pkg/ocm/output/nodepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func PrintNodePoolAutoscaling(autoscaling *cmv1.NodePoolAutoscaling) string {

func PrintNodePoolReplicas(autoscaling *cmv1.NodePoolAutoscaling, replicas int) string {
if autoscaling != nil {
return fmt.Sprintf("%d-%d",
return fmt.Sprintf(`
- Min replicas: %d
- Max replicas: %d`,
autoscaling.MinReplica(),
autoscaling.MaxReplica())
}
Expand Down

0 comments on commit a5553b3

Please sign in to comment.