[VOL-2941] Throwing an error if an adapter tries to register without specifying the adapter type
Change-Id: I67961b7926d83ad8504ded2b4920b43f770d5953
diff --git a/rw_core/core/adapter/manager.go b/rw_core/core/adapter/manager.go
index b6caea2..015e32d 100644
--- a/rw_core/core/adapter/manager.go
+++ b/rw_core/core/adapter/manager.go
@@ -19,6 +19,8 @@
import (
"context"
"fmt"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/status"
"sync"
"time"
@@ -220,6 +222,15 @@
logger.Debugw("RegisterAdapter", log.Fields{"adapterId": adapter.Id, "vendor": adapter.Vendor,
"currentReplica": adapter.CurrentReplica, "totalReplicas": adapter.TotalReplicas, "endpoint": adapter.Endpoint, "deviceTypes": deviceTypes.Items})
+ if adapter.Type == "" {
+ log.Errorw("adapter-not-specifying-type", log.Fields{
+ "adapterId": adapter.Id,
+ "vendor": adapter.Vendor,
+ "type": adapter.Type,
+ })
+ return nil, status.Error(codes.InvalidArgument, "adapter-not-specifying-type")
+ }
+
if aMgr.getAdapter(adapter.Id) != nil {
// Already registered - Adapter may have restarted. Trigger the reconcile process for that adapter
go func() {