From 2e44c23b1f56aa8ed732f3190f9c250f2346f7df Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Tue, 10 Oct 2023 18:58:20 +0300 Subject: [PATCH] databases: Fix DatabaseOptions.KV function (#1433) Co-authored-by: Andrew Starr-Bochicchio --- commands/displayers/database.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/displayers/database.go b/commands/displayers/database.go index e49987fbf..1e63153b2 100644 --- a/commands/displayers/database.go +++ b/commands/displayers/database.go @@ -333,19 +333,22 @@ func (do *DatabaseOptions) ColMap() map[string]string { func (do *DatabaseOptions) KV() []map[string]interface{} { engines := make([]string, 0) - if &do.DatabaseOptions.MongoDBOptions != nil { + nonEmptyOptionsFn := func(opt godo.DatabaseEngineOptions) bool { + return len(opt.Layouts) > 0 || len(opt.Regions) > 0 || len(opt.Versions) > 0 + } + if nonEmptyOptionsFn(do.DatabaseOptions.MongoDBOptions) { engines = append(engines, "mongodb") } - if &do.DatabaseOptions.RedisOptions != nil { + if nonEmptyOptionsFn(do.DatabaseOptions.RedisOptions) { engines = append(engines, "redis") } - if &do.DatabaseOptions.MySQLOptions != nil { + if nonEmptyOptionsFn(do.DatabaseOptions.MySQLOptions) { engines = append(engines, "mysql") } - if &do.DatabaseOptions.PostgresSQLOptions != nil { + if nonEmptyOptionsFn(do.DatabaseOptions.PostgresSQLOptions) { engines = append(engines, "pg") } - if &do.DatabaseOptions.KafkaOptions != nil { + if nonEmptyOptionsFn(do.DatabaseOptions.KafkaOptions) { engines = append(engines, "kafka") }