VOL-2742 - ensure component list is empty not null
JSON marshalling doesn't encode a nil array as [], but instead
encodes it as "null". This patch makes the list default to an empty
array so that it marshals to "[]" instead of "null".
Change-Id: I3dbaf9e231e5a5a8cd4d4475f558a98b1c0da1f8
diff --git a/internal/pkg/commands/loglevel.go b/internal/pkg/commands/loglevel.go
index 7887622..2bdd5cf 100644
--- a/internal/pkg/commands/loglevel.go
+++ b/internal/pkg/commands/loglevel.go
@@ -221,7 +221,9 @@
func (options *ListLogLevelsOpts) Execute(args []string) error {
var (
- data []model.LogLevel
+ // Initialize to empty as opposed to nil so that -o json will
+ // display empty list and not null VOL-2742
+ data []model.LogLevel = []model.LogLevel{}
componentList []string
logLevelConfig map[string]string
err error