Added LastCommunication and SinceLastCommunication to the adapter type.
Change-Id: Ibc63c6e38af27ff739a6e54f54d28a753d27fa56
diff --git a/VERSION b/VERSION
index 238d6e8..b0f3d96 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.7
+1.0.8
diff --git a/internal/pkg/commands/adapter.go b/internal/pkg/commands/adapter.go
index b777889..1a901bc 100644
--- a/internal/pkg/commands/adapter.go
+++ b/internal/pkg/commands/adapter.go
@@ -25,7 +25,7 @@
)
const (
- DEFAULT_OUTPUT_FORMAT = "table{{ .Id }}\t{{.Vendor}}\t{{.Version}}"
+ DEFAULT_OUTPUT_FORMAT = "table{{ .Id }}\t{{ .Vendor }}\t{{ .Version }}\t{{ .SinceLastCommunication }}"
)
type AdapterList struct {
diff --git a/pkg/model/adapter.go b/pkg/model/adapter.go
index d46039b..bfec875 100644
--- a/pkg/model/adapter.go
+++ b/pkg/model/adapter.go
@@ -16,20 +16,39 @@
package model
import (
+ "github.com/golang/protobuf/ptypes"
+ "github.com/golang/protobuf/ptypes/timestamp"
"github.com/jhump/protoreflect/dynamic"
+ "time"
)
type Adapter struct {
- Id string
- Vendor string
- Version string
- LogLevel string
+ Id string
+ Vendor string
+ Version string
+ LogLevel string
+ LastCommunication string
+ SinceLastCommunication string
}
func (adapter *Adapter) PopulateFrom(val *dynamic.Message) {
adapter.Id = val.GetFieldByName("id").(string)
adapter.Vendor = val.GetFieldByName("vendor").(string)
adapter.Version = val.GetFieldByName("version").(string)
+
+ if lastCommunication, err := val.TryGetFieldByName("last_communication"); err != nil {
+ adapter.LastCommunication = "UNKNOWN"
+ adapter.SinceLastCommunication = "UNKNOWN"
+ } else {
+ if lastCommunication, err := ptypes.Timestamp(lastCommunication.(*timestamp.Timestamp)); err != nil {
+ adapter.LastCommunication = "NEVER"
+ adapter.SinceLastCommunication = "NEVER"
+ } else {
+ adapter.LastCommunication = lastCommunication.Truncate(time.Second).Format(time.RFC3339)
+ adapter.SinceLastCommunication = time.Now().Sub(lastCommunication).Truncate(time.Second).String()
+ }
+ }
+
var config *dynamic.Message = val.GetFieldByName("config").(*dynamic.Message)
if config != nil {
adapter.LogLevel = GetEnumValue(config, "log_level")
diff --git a/vendor/modules.txt b/vendor/modules.txt
index cad57ab..2f99836 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -16,13 +16,13 @@
# github.com/golang/protobuf v1.3.1
github.com/golang/protobuf/proto
github.com/golang/protobuf/protoc-gen-go/descriptor
-github.com/golang/protobuf/jsonpb
github.com/golang/protobuf/ptypes
+github.com/golang/protobuf/ptypes/timestamp
+github.com/golang/protobuf/jsonpb
github.com/golang/protobuf/ptypes/empty
github.com/golang/protobuf/ptypes/struct
github.com/golang/protobuf/ptypes/any
github.com/golang/protobuf/ptypes/duration
-github.com/golang/protobuf/ptypes/timestamp
github.com/golang/protobuf/ptypes/wrappers
github.com/golang/protobuf/protoc-gen-go/plugin
# github.com/golang/snappy v0.0.1