Skip to content

Commit

Permalink
OCM-7269 | feat: Added list of kubeletconfigs to describe HCP machine…
Browse files Browse the repository at this point in the history
…pool output
  • Loading branch information
robpblake committed May 10, 2024
1 parent 47af22b commit 0c5dba3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions cmd/describe/machinepool/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Subnet:
Version: 4.12.24
Autorepair: No
Tuning configs:
Kubelet configs:
Additional security group IDs:
Node drain grace period: 1 minute
Message:
Expand All @@ -54,6 +55,7 @@ Subnet:
Version: 4.12.24
Autorepair: No
Tuning configs:
Kubelet configs:
Additional security group IDs:
Node drain grace period: 1 minute
Message:
Expand All @@ -74,6 +76,7 @@ Subnet:
Version: 4.12.24
Autorepair: No
Tuning configs:
Kubelet configs:
Additional security group IDs:
Node drain grace period: 1 minute
Message:
Expand Down
4 changes: 3 additions & 1 deletion pkg/machinepool/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var nodePoolOutputString string = "\n" +
"Version: %s\n" +
"Autorepair: %s\n" +
"Tuning configs: %s\n" +
"Kubelet configs: %s\n" +
"Additional security group IDs: %s\n" +
"Node drain grace period: %s\n" +
"Message: %s\n"
Expand Down Expand Up @@ -76,7 +77,8 @@ func nodePoolOutput(clusterId string, nodePool *cmv1.NodePool) string {
nodePool.Subnet(),
ocmOutput.PrintNodePoolVersion(nodePool.Version()),
ocmOutput.PrintNodePoolAutorepair(nodePool.AutoRepair()),
ocmOutput.PrintNodePoolTuningConfigs(nodePool.TuningConfigs()),
ocmOutput.PrintNodePoolConfigs(nodePool.TuningConfigs()),
ocmOutput.PrintNodePoolConfigs(nodePool.KubeletConfigs()),
ocmOutput.PrintNodePoolAdditionalSecurityGroups(nodePool.AWSNodePool()),
ocmOutput.PrintNodeDrainGracePeriod(nodePool.NodeDrainGracePeriod()),
ocmOutput.PrintNodePoolMessage(nodePool.Status()),
Expand Down
10 changes: 5 additions & 5 deletions pkg/machinepool/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ var _ = Describe("Output", Ordered, func() {
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)
ID("1")).AutoRepair(false).TuningConfigs("test-tc").
KubeletConfigs("test-kc").Labels(labels).Taints(taintsBuilder)
nodePool, err := nodePoolBuilder.Build()
Expect(err).ToNot(HaveOccurred())
labelsOutput := ocmOutput.PrintLabels(labels)
Expand All @@ -114,7 +114,7 @@ var _ = Describe("Output", Ordered, func() {

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

result := nodePoolOutput("test-cluster", nodePool)
Expect(out).To(Equal(result))
Expand All @@ -123,15 +123,15 @@ var _ = Describe("Output", Ordered, func() {
nodePoolBuilder := *cmv1.NewNodePool().ID("test-mp").Replicas(4).
AvailabilityZone("test-az").Subnet("test-subnets").Version(cmv1.NewVersion().
ID("1")).AutoRepair(false).TuningConfigs("test-tc").
Labels(labels).Taints(taintsBuilder)
KubeletConfigs("test-kc").Labels(labels).Taints(taintsBuilder)
nodePool, err := nodePoolBuilder.Build()
Expect(err).ToNot(HaveOccurred())
labelsOutput := ocmOutput.PrintLabels(labels)
taintsOutput := ocmOutput.PrintTaints([]*cmv1.Taint{taint})

out := fmt.Sprintf(nodePoolOutputString,
"test-mp", "test-cluster", "No", "4", "", "", labelsOutput, "", taintsOutput, "test-az",
"test-subnets", "1", "No", "test-tc", "", "", "")
"test-subnets", "1", "No", "test-tc", "test-kc", "", "", "")

result := nodePoolOutput("test-cluster", nodePool)
Expect(out).To(Equal(result))
Expand Down
6 changes: 3 additions & 3 deletions pkg/ocm/output/nodepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func PrintNodePoolAutorepair(autorepair bool) string {
return output.No
}

func PrintNodePoolTuningConfigs(tuningConfigs []string) string {
if len(tuningConfigs) == 0 {
func PrintNodePoolConfigs(configs []string) string {
if len(configs) == 0 {
return ""
}
return strings.Join(tuningConfigs, ",")
return strings.Join(configs, ",")
}

func PrintNodeDrainGracePeriod(period *cmv1.Value) string {
Expand Down

0 comments on commit 0c5dba3

Please sign in to comment.