VOL-1900 lint warning fixes rw_core
Change-Id: Icaa84d7ce24163da90c91ff2babcbb78ff4e9141
diff --git a/rw_core/mocks/adapter.go b/rw_core/mocks/adapter.go
index a510e58..4908573 100644
--- a/rw_core/mocks/adapter.go
+++ b/rw_core/mocks/adapter.go
@@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package mocks
import (
+ "strconv"
+ "strings"
+ "sync"
+
"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
ic "github.com/opencord/voltha-protos/v2/go/inter_container"
of "github.com/opencord/voltha-protos/v2/go/openflow_13"
"github.com/opencord/voltha-protos/v2/go/voltha"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
- "strconv"
- "strings"
- "sync"
)
func macAddressToUint32Array(mac string) []uint32 {
@@ -41,11 +43,13 @@
return result
}
+// Adapter represents adapter attributes
type Adapter struct {
coreProxy adapterif.CoreProxy
devices sync.Map
}
+// NewAdapter creates adapter instance
func NewAdapter(cp adapterif.CoreProxy) *Adapter {
return &Adapter{
coreProxy: cp,
@@ -58,10 +62,6 @@
}
}
-func (ta *Adapter) deleteDevice(id string) {
- ta.devices.Delete(id)
-}
-
func (ta *Adapter) getDevice(id string) *voltha.Device {
if val, ok := ta.devices.Load(id); ok && val != nil {
if device, ok := val.(*voltha.Device); ok {
@@ -80,75 +80,98 @@
return nil
}
-func (ta *Adapter) Adapter_descriptor() error {
+// Adapter_descriptor -
+func (ta *Adapter) Adapter_descriptor() error { // nolint
return nil
}
-func (ta *Adapter) Device_types() (*voltha.DeviceTypes, error) {
+
+// Device_types -
+func (ta *Adapter) Device_types() (*voltha.DeviceTypes, error) { // nolint
return nil, nil
}
+
+// Health -
func (ta *Adapter) Health() (*voltha.HealthStatus, error) {
return nil, nil
}
-func (ta *Adapter) Adopt_device(device *voltha.Device) error {
+
+// Adopt_device -
+func (ta *Adapter) Adopt_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Reconcile_device(device *voltha.Device) error {
+// Reconcile_device -
+func (ta *Adapter) Reconcile_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Abandon_device(device *voltha.Device) error {
+// Abandon_device -
+func (ta *Adapter) Abandon_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Disable_device(device *voltha.Device) error {
+// Disable_device -
+func (ta *Adapter) Disable_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device -
+func (ta *Adapter) Reenable_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Reboot_device(device *voltha.Device) error {
+// Reboot_device -
+func (ta *Adapter) Reboot_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Self_test_device(device *voltha.Device) error {
+// Self_test_device -
+func (ta *Adapter) Self_test_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Delete_device(device *voltha.Device) error {
+// Delete_device -
+func (ta *Adapter) Delete_device(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Get_device_details(device *voltha.Device) error {
+// Get_device_details -
+func (ta *Adapter) Get_device_details(device *voltha.Device) error { // nolint
return nil
}
-func (ta *Adapter) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error {
+// Update_flows_bulk -
+func (ta *Adapter) Update_flows_bulk(device *voltha.Device, flows *voltha.Flows, groups *voltha.FlowGroups, flowMetadata *voltha.FlowMetadata) error { // nolint
return nil
}
-func (ta *Adapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error {
- return nil
-}
-func (ta *Adapter) Update_pm_config(device *voltha.Device, pm_configs *voltha.PmConfigs) error {
+// Update_flows_incrementally -
+func (ta *Adapter) Update_flows_incrementally(device *voltha.Device, flows *of.FlowChanges, groups *of.FlowGroupChanges, flowMetadata *voltha.FlowMetadata) error { // nolint
return nil
}
-func (ta *Adapter) Receive_packet_out(deviceId string, egress_port_no int, msg *of.OfpPacketOut) error {
+// Update_pm_config -
+func (ta *Adapter) Update_pm_config(device *voltha.Device, pmConfigs *voltha.PmConfigs) error { // nolint
return nil
}
-func (ta *Adapter) Suppress_alarm(filter *voltha.AlarmFilter) error {
+// Receive_packet_out -
+func (ta *Adapter) Receive_packet_out(deviceID string, egressPortNo int, msg *of.OfpPacketOut) error { // nolint
return nil
}
-func (ta *Adapter) Unsuppress_alarm(filter *voltha.AlarmFilter) error {
+// Suppress_alarm -
+func (ta *Adapter) Suppress_alarm(filter *voltha.AlarmFilter) error { // nolint
return nil
}
-func (ta *Adapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+// Unsuppress_alarm -
+func (ta *Adapter) Unsuppress_alarm(filter *voltha.AlarmFilter) error { // nolint
+ return nil
+}
+
+// Get_ofp_device_info -
+func (ta *Adapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
return &ic.SwitchCapability{
Desc: &of.OfpDesc{
HwDesc: "adapter_mock",
@@ -166,7 +189,8 @@
}, nil
}
-func (ta *Adapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info -
+func (ta *Adapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
capability := uint32(of.OfpPortFeatures_OFPPF_1GB_FD | of.OfpPortFeatures_OFPPF_FIBER)
return &ic.PortCapability{
Port: &voltha.LogicalPort{
@@ -181,31 +205,37 @@
MaxSpeed: uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
},
DeviceId: device.Id,
- DevicePortNo: uint32(port_no),
+ DevicePortNo: uint32(portNo),
},
}, nil
}
-func (ta *Adapter) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error {
+// Process_inter_adapter_message -
+func (ta *Adapter) Process_inter_adapter_message(msg *ic.InterAdapterMessage) error { // nolint
return nil
}
-func (ta *Adapter) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Download_image -
+func (ta *Adapter) Download_image(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
return nil, nil
}
-func (ta *Adapter) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Get_image_download_status -
+func (ta *Adapter) Get_image_download_status(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
return nil, nil
}
-func (ta *Adapter) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Cancel_image_download -
+func (ta *Adapter) Cancel_image_download(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
return nil, nil
}
-func (ta *Adapter) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Activate_image_update -
+func (ta *Adapter) Activate_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
return nil, nil
}
-func (ta *Adapter) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) {
+// Revert_image_update -
+func (ta *Adapter) Revert_image_update(device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error) { // nolint
return nil, nil
}
diff --git a/rw_core/mocks/adapter_olt.go b/rw_core/mocks/adapter_olt.go
index 89f6c20..7cf0d47 100644
--- a/rw_core/mocks/adapter_olt.go
+++ b/rw_core/mocks/adapter_olt.go
@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package mocks
import (
"context"
"fmt"
+ "strings"
+
"github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
@@ -25,24 +28,26 @@
ic "github.com/opencord/voltha-protos/v2/go/inter_container"
of "github.com/opencord/voltha-protos/v2/go/openflow_13"
"github.com/opencord/voltha-protos/v2/go/voltha"
- "strings"
)
const (
numONUPerOLT = 4
)
+// OLTAdapter represent OLT adapter
type OLTAdapter struct {
Adapter
}
+// NewOLTAdapter - creates OLT adapter instance
func NewOLTAdapter(cp adapterif.CoreProxy) *OLTAdapter {
a := &OLTAdapter{}
a.coreProxy = cp
return a
}
-func (oltA *OLTAdapter) Adopt_device(device *voltha.Device) error {
+// Adopt_device creates new handler for added device
+func (oltA *OLTAdapter) Adopt_device(device *voltha.Device) error { // nolint
go func() {
d := proto.Clone(device).(*voltha.Device)
d.Root = true
@@ -112,7 +117,8 @@
return nil
}
-func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) {
+// Get_ofp_device_info returns ofp device info
+func (oltA *OLTAdapter) Get_ofp_device_info(device *voltha.Device) (*ic.SwitchCapability, error) { // nolint
if d := oltA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
}
@@ -133,7 +139,8 @@
}, nil
}
-func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info returns ofp port info
+func (oltA *OLTAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
if d := oltA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
}
@@ -151,16 +158,18 @@
MaxSpeed: uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
},
DeviceId: device.Id,
- DevicePortNo: uint32(port_no),
+ DevicePortNo: uint32(portNo),
},
}, nil
}
+// GetNumONUPerOLT returns number of ONUs per OLT
func (oltA *OLTAdapter) GetNumONUPerOLT() int {
return numONUPerOLT
}
-func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error {
+// Disable_device disables device
+func (oltA *OLTAdapter) Disable_device(device *voltha.Device) error { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
@@ -192,7 +201,8 @@
return nil
}
-func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device reenables device
+func (oltA *OLTAdapter) Reenable_device(device *voltha.Device) error { // nolint
go func() {
if d := oltA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
diff --git a/rw_core/mocks/adapter_olt_test.go b/rw_core/mocks/adapter_olt_test.go
index 6d61e1f..aa91ab5 100644
--- a/rw_core/mocks/adapter_olt_test.go
+++ b/rw_core/mocks/adapter_olt_test.go
@@ -17,8 +17,9 @@
package mocks
import (
- "github.com/opencord/voltha-lib-go/v2/pkg/adapters"
"testing"
+
+ "github.com/opencord/voltha-lib-go/v2/pkg/adapters"
)
func TestOLTAdapterImplementsIAdapter(t *testing.T) {
diff --git a/rw_core/mocks/adapter_onu.go b/rw_core/mocks/adapter_onu.go
index 66a3538..bb6f58a 100644
--- a/rw_core/mocks/adapter_onu.go
+++ b/rw_core/mocks/adapter_onu.go
@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package mocks
import (
"context"
"fmt"
+ "strings"
+
"github.com/gogo/protobuf/proto"
"github.com/opencord/voltha-lib-go/v2/pkg/adapters/adapterif"
com "github.com/opencord/voltha-lib-go/v2/pkg/adapters/common"
@@ -25,21 +28,23 @@
ic "github.com/opencord/voltha-protos/v2/go/inter_container"
of "github.com/opencord/voltha-protos/v2/go/openflow_13"
"github.com/opencord/voltha-protos/v2/go/voltha"
- "strings"
)
+// ONUAdapter represent ONU adapter attributes
type ONUAdapter struct {
coreProxy adapterif.CoreProxy
Adapter
}
+// NewONUAdapter creates ONU adapter
func NewONUAdapter(cp adapterif.CoreProxy) *ONUAdapter {
a := &ONUAdapter{}
a.coreProxy = cp
return a
}
-func (onuA *ONUAdapter) Adopt_device(device *voltha.Device) error {
+// Adopt_device creates new handler for added device
+func (onuA *ONUAdapter) Adopt_device(device *voltha.Device) error { // nolint
go func() {
d := proto.Clone(device).(*voltha.Device)
d.Root = false
@@ -89,7 +94,7 @@
Peers: []*voltha.Port_PeerPort{{DeviceId: d.ParentId, // Peer device is OLT
PortNo: uniPortNo}}, // Peer port is UNI port
}
- if err := onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
+ if err = onuA.coreProxy.PortCreated(context.TODO(), d.Id, ponPort); err != nil {
log.Fatalf("PortCreated-failed-%s", err)
}
@@ -111,7 +116,8 @@
return nil
}
-func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, port_no int64) (*ic.PortCapability, error) {
+// Get_ofp_port_info returns ofp device info
+func (onuA *ONUAdapter) Get_ofp_port_info(device *voltha.Device, portNo int64) (*ic.PortCapability, error) { // nolint
if d := onuA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
}
@@ -129,12 +135,13 @@
MaxSpeed: uint32(of.OfpPortFeatures_OFPPF_1GB_FD),
},
DeviceId: device.Id,
- DevicePortNo: uint32(port_no),
+ DevicePortNo: uint32(portNo),
},
}, nil
}
-func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error {
+// Disable_device disables device
+func (onuA *ONUAdapter) Disable_device(device *voltha.Device) error { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
@@ -158,7 +165,8 @@
return nil
}
-func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error {
+// Reenable_device reenables device
+func (onuA *ONUAdapter) Reenable_device(device *voltha.Device) error { // nolint
go func() {
if d := onuA.getDevice(device.Id); d == nil {
log.Fatalf("device-not-found-%s", device.Id)
diff --git a/rw_core/mocks/device_manager.go b/rw_core/mocks/device_manager.go
index c8bf1ca..1968efa 100644
--- a/rw_core/mocks/device_manager.go
+++ b/rw_core/mocks/device_manager.go
@@ -13,129 +13,166 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package mocks
import (
"context"
+
"github.com/opencord/voltha-protos/v2/go/voltha"
)
+// DeviceManager -
type DeviceManager struct {
}
-func (dm *DeviceManager) GetDevice(deviceId string) (*voltha.Device, error) {
+// GetDevice -
+func (dm *DeviceManager) GetDevice(deviceID string) (*voltha.Device, error) {
return nil, nil
}
-func (dm *DeviceManager) IsRootDevice(deviceId string) (bool, error) {
+
+// IsRootDevice -
+func (dm *DeviceManager) IsRootDevice(deviceID string) (bool, error) {
return false, nil
}
+// NotifyInvalidTransition -
func (dm *DeviceManager) NotifyInvalidTransition(pcDevice *voltha.Device) error {
return nil
}
+// SetAdminStateToEnable -
func (dm *DeviceManager) SetAdminStateToEnable(cDevice *voltha.Device) error {
return nil
}
+// CreateLogicalDevice -
func (dm *DeviceManager) CreateLogicalDevice(cDevice *voltha.Device) error {
return nil
}
+// SetupUNILogicalPorts -
func (dm *DeviceManager) SetupUNILogicalPorts(cDevice *voltha.Device) error {
return nil
}
+// DisableAllChildDevices -
func (dm *DeviceManager) DisableAllChildDevices(cDevice *voltha.Device) error {
return nil
}
+// DeleteLogicalDevice -
func (dm *DeviceManager) DeleteLogicalDevice(cDevice *voltha.Device) error {
return nil
}
+// DeleteLogicalPorts -
func (dm *DeviceManager) DeleteLogicalPorts(cDevice *voltha.Device) error {
return nil
}
+// DeleteAllChildDevices -
func (dm *DeviceManager) DeleteAllChildDevices(cDevice *voltha.Device) error {
return nil
}
+// RunPostDeviceDelete -
func (dm *DeviceManager) RunPostDeviceDelete(cDevice *voltha.Device) error {
return nil
}
+// ListDevices -
func (dm *DeviceManager) ListDevices() (*voltha.Devices, error) {
return nil, nil
}
+// ListDeviceIds -
func (dm *DeviceManager) ListDeviceIds() (*voltha.IDs, error) {
return nil, nil
}
+// ReconcileDevices -
func (dm *DeviceManager) ReconcileDevices(ctx context.Context, ids *voltha.IDs, ch chan interface{}) {
}
+// CreateDevice -
func (dm *DeviceManager) CreateDevice(ctx context.Context, device *voltha.Device, ch chan interface{}) {
}
+// EnableDevice -
func (dm *DeviceManager) EnableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
}
+// DisableDevice -
func (dm *DeviceManager) DisableDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
}
+// RebootDevice -
func (dm *DeviceManager) RebootDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
}
+// DeleteDevice -
func (dm *DeviceManager) DeleteDevice(ctx context.Context, id *voltha.ID, ch chan interface{}) {
}
+// StopManagingDevice -
func (dm *DeviceManager) StopManagingDevice(id string) {
}
+// DownloadImage -
func (dm *DeviceManager) DownloadImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
}
+// CancelImageDownload -
func (dm *DeviceManager) CancelImageDownload(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
}
+// ActivateImage -
func (dm *DeviceManager) ActivateImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
}
+// RevertImage -
func (dm *DeviceManager) RevertImage(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
}
+// GetImageDownloadStatus -
func (dm *DeviceManager) GetImageDownloadStatus(ctx context.Context, img *voltha.ImageDownload, ch chan interface{}) {
}
-func (dm *DeviceManager) UpdateImageDownload(deviceId string, img *voltha.ImageDownload) error {
+// UpdateImageDownload -
+func (dm *DeviceManager) UpdateImageDownload(deviceID string, img *voltha.ImageDownload) error {
return nil
}
+// SimulateAlarm -
func (dm *DeviceManager) SimulateAlarm(ctx context.Context, simulatereq *voltha.SimulateAlarmRequest, ch chan interface{}) {
}
+// GetImageDownload -
func (dm *DeviceManager) GetImageDownload(ctx context.Context, img *voltha.ImageDownload) (*voltha.ImageDownload, error) {
return nil, nil
}
-func (dm *DeviceManager) ListImageDownloads(ctx context.Context, deviceId string) (*voltha.ImageDownloads, error) {
+// ListImageDownloads -
+func (dm *DeviceManager) ListImageDownloads(ctx context.Context, deviceID string) (*voltha.ImageDownloads, error) {
return nil, nil
}
+// UpdatePmConfigs -
func (dm *DeviceManager) UpdatePmConfigs(ctx context.Context, pmConfigs *voltha.PmConfigs, ch chan interface{}) {
}
-func (dm *DeviceManager) ListPmConfigs(ctx context.Context, deviceId string) (*voltha.PmConfigs, error) {
+// ListPmConfigs -
+func (dm *DeviceManager) ListPmConfigs(ctx context.Context, deviceID string) (*voltha.PmConfigs, error) {
return nil, nil
}
-func (dm *DeviceManager) DeletePeerPorts(fromDeviceId string, deviceId string) error {
+// DeletePeerPorts -
+func (dm *DeviceManager) DeletePeerPorts(fromDeviceID string, deviceID string) error {
return nil
}
+// ProcessTransition -
func (dm *DeviceManager) ProcessTransition(previous *voltha.Device, current *voltha.Device) error {
return nil
}
diff --git a/rw_core/mocks/device_manager_test.go b/rw_core/mocks/device_manager_test.go
index ab2226b..e92d62f 100644
--- a/rw_core/mocks/device_manager_test.go
+++ b/rw_core/mocks/device_manager_test.go
@@ -17,14 +17,15 @@
package mocks
import (
- "github.com/opencord/voltha-go/rw_core/coreIf"
"testing"
+
+ "github.com/opencord/voltha-go/rw_core/coreif"
)
func TestDeviceManagerImplementsDeviceManagerIf(t *testing.T) {
deviceMgr := &DeviceManager{}
- if _, ok := interface{}(deviceMgr).(coreIf.DeviceManager); !ok {
- t.Error("Device manager does not implement the coreIf.DeviceManager interface")
+ if _, ok := interface{}(deviceMgr).(coreif.DeviceManager); !ok {
+ t.Error("Device manager does not implement the coreif.DeviceManager interface")
}
}