VOL-2626 fix SCA issues
Change-Id: I5a85610b526cd025ac4ec8ebf568e646e5729c2a
diff --git a/VERSION b/VERSION
index 66c4c22..7ee7020 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.9
+1.0.10
diff --git a/internal/pkg/commands/command.go b/internal/pkg/commands/command.go
index 6b5b56b..d839907 100644
--- a/internal/pkg/commands/command.go
+++ b/internal/pkg/commands/command.go
@@ -95,6 +95,7 @@
Server string `short:"s" long:"server" default:"" value-name:"SERVER:PORT" description:"IP/Host and port of VOLTHA"`
Kafka string `short:"k" long:"kafka" default:"" value-name:"SERVER:PORT" description:"IP/Host and port of Kafka"`
// Do not set the default for the API version here, else it will override the value read in the config
+ // nolint: staticcheck
ApiVersion string `short:"a" long:"apiversion" description:"API version" value-name:"VERSION" choice:"v1" choice:"v2" choice:"v3"`
Debug bool `short:"d" long:"debug" description:"Enable debug mode"`
UseTLS bool `long:"tls" description:"Use TLS"`
@@ -113,8 +114,9 @@
)
type OutputOptions struct {
- Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
- Quiet bool `short:"q" long:"quiet" description:"Output only the IDs of the objects"`
+ Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
+ Quiet bool `short:"q" long:"quiet" description:"Output only the IDs of the objects"`
+ // nolint: staticcheck
OutputAs string `short:"o" long:"outputas" default:"table" choice:"table" choice:"json" choice:"yaml" description:"Type of output to generate"`
NameLimit int `short:"l" long:"namelimit" default:"-1" value-name:"LIMIT" description:"Limit the depth (length) in the table column name"`
}
@@ -126,8 +128,9 @@
}
type OutputOptionsJson struct {
- Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
- Quiet bool `short:"q" long:"quiet" description:"Output only the IDs of the objects"`
+ Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
+ Quiet bool `short:"q" long:"quiet" description:"Output only the IDs of the objects"`
+ // nolint: staticcheck
OutputAs string `short:"o" long:"outputas" default:"json" choice:"table" choice:"json" choice:"yaml" description:"Type of output to generate"`
NameLimit int `short:"l" long:"namelimit" default:"-1" value-name:"LIMIT" description:"Limit the depth (length) in the table column name"`
}
diff --git a/internal/pkg/commands/events.go b/internal/pkg/commands/events.go
index deacb79..a9d20c8 100644
--- a/internal/pkg/commands/events.go
+++ b/internal/pkg/commands/events.go
@@ -41,7 +41,8 @@
)
type EventListenOpts struct {
- Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
+ Format string `long:"format" value-name:"FORMAT" default:"" description:"Format to use to output structured data"`
+ // nolint: staticcheck
OutputAs string `short:"o" long:"outputas" default:"table" choice:"table" choice:"json" choice:"yaml" description:"Type of output to generate"`
Filter string `short:"f" long:"filter" default:"" value-name:"FILTER" description:"Only display results that match filter"`
Follow bool `short:"F" long:"follow" description:"Continue to consume until CTRL-C is pressed"`
@@ -194,17 +195,17 @@
kpiIntf, err := m.TryGetFieldByName("kpi_event2")
if err == nil {
kpi, ok := kpiIntf.(*dynamic.Message)
- if ok == true && kpi != nil {
+ if ok && kpi != nil {
sliceListIntf, err := kpi.TryGetFieldByName("slice_data")
if err == nil {
sliceIntf, ok := sliceListIntf.([]interface{})
- if ok == true && len(sliceIntf) > 0 {
+ if ok && len(sliceIntf) > 0 {
slice, ok := sliceIntf[0].(*dynamic.Message)
- if ok == true && slice != nil {
+ if ok && slice != nil {
metadataIntf, err := slice.TryGetFieldByName("metadata")
if err == nil {
metadata, ok := metadataIntf.(*dynamic.Message)
- if ok == true && metadata != nil {
+ if ok && metadata != nil {
deviceIdIntf, err := metadataIntf.(*dynamic.Message).TryGetFieldByName("device_id")
if err == nil {
device_ids[deviceIdIntf.(string)] = slice
@@ -227,7 +228,7 @@
deviceEventIntf, err := m.TryGetFieldByName("device_event")
if err == nil {
deviceEvent, ok := deviceEventIntf.(*dynamic.Message)
- if ok == true && deviceEvent != nil {
+ if ok && deviceEvent != nil {
deviceEventNameIntf, err := deviceEvent.TryGetFieldByName("device_event_name")
if err == nil {
deviceEventName, ok := deviceEventNameIntf.(string)
@@ -247,14 +248,14 @@
device_id_keys := make([]string, len(device_ids))
i := 0
- for k, _ := range device_ids {
+ for k := range device_ids {
device_id_keys[i] = k
i++
}
title_keys := make([]string, len(titles))
i = 0
- for k, _ := range titles {
+ for k := range titles {
title_keys[i] = k
i++
}
@@ -312,6 +313,9 @@
// This is a very long-winded way to get a message descriptor
descriptor, err := GetDescriptorSource()
+ if err != nil {
+ return nil, err
+ }
// get the symbol for voltha.events
eventSymbol, err := descriptor.FindSymbol("voltha.Event")
@@ -469,10 +473,11 @@
// Print it
if options.ShowBody {
- PrintMessage(grpcurlFormatter, eventMessage, msg.Value)
+ if err := PrintMessage(grpcurlFormatter, eventMessage, msg.Value); err != nil {
+ log.Printf("%v\n", err)
+ }
} else {
- err := PrintEventHeader(options.OutputAs, outputFormat, hdr)
- if err != nil {
+ if err := PrintEventHeader(options.OutputAs, outputFormat, hdr); err != nil {
log.Printf("%v\n", err)
}
}
diff --git a/pkg/model/adapter.go b/pkg/model/adapter.go
index bfec875..400ac07 100644
--- a/pkg/model/adapter.go
+++ b/pkg/model/adapter.go
@@ -45,7 +45,7 @@
adapter.SinceLastCommunication = "NEVER"
} else {
adapter.LastCommunication = lastCommunication.Truncate(time.Second).Format(time.RFC3339)
- adapter.SinceLastCommunication = time.Now().Sub(lastCommunication).Truncate(time.Second).String()
+ adapter.SinceLastCommunication = time.Since(lastCommunication).Truncate(time.Second).String()
}
}