Skip to content

Commit a74b3cd

Browse files
Adjust plans printer for new supported engines (vultr#505)
1 parent 63bbe38 commit a74b3cd

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

cmd/database/printer.go

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (d *DBsPrinter) Data() [][]string { //nolint:funlen,gocyclo
148148
data = append(data, []string{" "})
149149
}
150150

151-
if d.DBs[i].DatabaseEngine == "redis" || d.DBs[i].DatabaseEngine == "valkey" {
151+
if d.DBs[i].DatabaseEngine == "valkey" {
152152
data = append(data, []string{"EVICTION POLICY", d.DBs[i].EvictionPolicy})
153153
}
154154

@@ -249,7 +249,7 @@ func (d *DBsPrinter) Data() [][]string { //nolint:funlen,gocyclo
249249
data = append(data, []string{" "})
250250
}
251251

252-
if d.DBs[i].ReadReplicas[j].DatabaseEngine == "redis" || d.DBs[i].ReadReplicas[j].DatabaseEngine == "valkey" {
252+
if d.DBs[i].ReadReplicas[j].DatabaseEngine == "valkey" {
253253
data = append(data, []string{"EVICTION POLICY", d.DBs[i].ReadReplicas[j].EvictionPolicy})
254254
}
255255

@@ -404,7 +404,7 @@ func (d *DBPrinter) Data() [][]string { //nolint:funlen,gocyclo
404404
data = append(data, []string{" "})
405405
}
406406

407-
if d.DB.DatabaseEngine == "redis" || d.DB.DatabaseEngine == "valkey" {
407+
if d.DB.DatabaseEngine == "valkey" {
408408
data = append(data, []string{"EVICTION POLICY", d.DB.EvictionPolicy})
409409
}
410410

@@ -505,7 +505,7 @@ func (d *DBPrinter) Data() [][]string { //nolint:funlen,gocyclo
505505
data = append(data, []string{" "})
506506
}
507507

508-
if d.DB.ReadReplicas[i].DatabaseEngine == "redis" || d.DB.ReadReplicas[i].DatabaseEngine == "valkey" {
508+
if d.DB.ReadReplicas[i].DatabaseEngine == "valkey" {
509509
data = append(data, []string{"EVICTION POLICY", d.DB.ReadReplicas[i].EvictionPolicy})
510510
}
511511

@@ -614,18 +614,41 @@ func (p *PlansPrinter) Data() [][]string {
614614
[]string{"ID", p.Plans[i].ID},
615615
[]string{"NUMBER OF NODES", strconv.Itoa(p.Plans[i].NumberOfNodes)},
616616
[]string{"TYPE", p.Plans[i].Type},
617-
[]string{"VCPU COUNT", strconv.Itoa(p.Plans[i].VCPUCount)},
618-
[]string{"RAM", strconv.Itoa(p.Plans[i].RAM)},
619-
[]string{"DISK", strconv.Itoa(p.Plans[i].Disk)},
620-
[]string{"MONTHLY COST", strconv.Itoa(p.Plans[i].MonthlyCost)},
617+
)
621618

622-
[]string{" "},
619+
if !*p.Plans[i].SupportedEngines.Kafka {
620+
data = append(data,
621+
[]string{"VCPU COUNT", strconv.Itoa(p.Plans[i].VCPUCount)},
622+
[]string{"RAM", strconv.Itoa(p.Plans[i].RAM)},
623+
)
624+
}
625+
626+
if !*p.Plans[i].SupportedEngines.Valkey {
627+
data = append(data,
628+
[]string{"DISK", strconv.Itoa(p.Plans[i].Disk)},
629+
)
630+
}
623631

632+
data = append(data,
633+
[]string{"MONTHLY COST", strconv.Itoa(p.Plans[i].MonthlyCost)},
634+
[]string{" "},
624635
[]string{"SUPPORTED ENGINES"},
625636
[]string{"MYSQL", strconv.FormatBool(*p.Plans[i].SupportedEngines.MySQL)},
626637
[]string{"PG", strconv.FormatBool(*p.Plans[i].SupportedEngines.PG)},
638+
[]string{"VALKEY", strconv.FormatBool(*p.Plans[i].SupportedEngines.Valkey)},
639+
[]string{"KAFKA", strconv.FormatBool(*p.Plans[i].SupportedEngines.Kafka)},
640+
[]string{" "},
627641
)
628642

643+
if *p.Plans[i].SupportedEngines.MySQL || *p.Plans[i].SupportedEngines.PG {
644+
data = append(data,
645+
[]string{"MAX CONNECTIONS"},
646+
[]string{"MYSQL", strconv.Itoa(p.Plans[i].MaxConnections.MySQL)},
647+
[]string{"PG", strconv.Itoa(p.Plans[i].MaxConnections.PG)},
648+
[]string{" "},
649+
)
650+
}
651+
629652
data = append(data,
630653
[]string{"LOCATIONS", printer.ArrayOfStringsToString(p.Plans[i].Locations)},
631654
[]string{"---------------------------"},

0 commit comments

Comments
 (0)