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/VERSION b/VERSION
index a970716..3ec1c88 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.15
+1.0.16-dev
diff --git a/internal/pkg/commands/events.go b/internal/pkg/commands/events.go
index a9d20c8..5aa9751 100644
--- a/internal/pkg/commands/events.go
+++ b/internal/pkg/commands/events.go
@@ -406,7 +406,7 @@
if options.ShowBody {
if options.OutputAs == "json" {
// need a descriptor source, any method will do
- descriptor, _, _ := GetMethod("device-list")
+ descriptor, _, err := GetMethod("device-list")
if err != nil {
return err
}
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