Fixing golang linters for VGC
Change-Id: I386d232c74ab47e24d92c18800dc144120b920da
diff --git a/internal/pkg/application/minor_upgrade.go b/internal/pkg/application/minor_upgrade.go
index a0bba15..4d6b3d6 100644
--- a/internal/pkg/application/minor_upgrade.go
+++ b/internal/pkg/application/minor_upgrade.go
@@ -16,21 +16,22 @@
package application
import (
- "errors"
"context"
+ "errors"
"net"
- "voltha-go-controller/internal/pkg/types"
"strings"
- "github.com/google/gopacket/layers"
"voltha-go-controller/database"
+ common "voltha-go-controller/internal/pkg/types"
"voltha-go-controller/log"
+
+ "github.com/google/gopacket/layers"
)
type paramsUpdationFunc func(cntx context.Context, hash string, value interface{}) error
-//map to store conversion functions
+// map to store conversion functions
var updationMap = map[string]paramsUpdationFunc{
database.VnetPath: updateVnets,
database.VpvPath: updateVpvs,
@@ -53,43 +54,42 @@
return nil
}
-//This function modifyies the old data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateServices(cntx context.Context, hash string, value interface{}) error {
param := value.(*VoltService)
param.VnetID = VnetKey(param.SVlan, param.CVlan, param.UniVlan)
return nil
}
-//This function modifyies the old data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateVnets(cntx context.Context, hash string, value interface{}) error {
param := value.(*VoltVnet)
newKey := VnetKey(param.SVlan, param.CVlan, param.UniVlan)
if newKey != hash {
- //Delete the older key
+ // Delete the older key
_ = db.DelVnet(cntx, hash)
} else {
- //Update SVlan Tag Protocol id param with default valud if not present
+ // Update SVlan Tag Protocol id param with default valud if not present
if param.SVlanTpid == 0 {
param.SVlanTpid = layers.EthernetTypeDot1Q
}
}
param.Name = newKey
if param.DevicesList == nil || len(param.DevicesList) == 0 {
- param.DevicesList = append(param.DevicesList, "") //Empty OLT serial number as of now since submgr won't have proper serial num
+ param.DevicesList = append(param.DevicesList, "") // Empty OLT serial number as of now since submgr won't have proper serial num
}
return nil
}
-//This function modifyies the old data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateVpvs(cntx context.Context, hash string, value interface{}) error {
-
//var param VoltPortVnet
param := value.(*VoltPortVnet)
- //Update SVlan Tag Protocol id param with default valud if not present
+ // Update SVlan Tag Protocol id param with default valud if not present
if param.SVlanTpid == 0 {
param.SVlanTpid = layers.EthernetTypeDot1Q
}
@@ -99,9 +99,9 @@
return nil
}
- //Add the vpv under new path
+ // Add the vpv under new path
param.WriteToDb(cntx)
- //delete the older path
+ // delete the older path
fullPath := database.BasePath + database.VpvPath + hash
if err := db.Del(cntx, fullPath); err != nil {
logger.Errorw(ctx, "Vpv Delete from DB failed", log.Fields{"Error": err, "key": fullPath})
@@ -112,11 +112,10 @@
func updateMvlans(cntx context.Context, hash string, value interface{}) error {
param := value.(*MvlanProfile)
if param.DevicesList == nil || len(param.DevicesList) == 0 {
- param.DevicesList = make(map[string]OperInProgress) //Empty OLT serial number as of now since submgr won't have proper serial num
+ param.DevicesList = make(map[string]OperInProgress) // Empty OLT serial number as of now since submgr won't have proper serial num
if err := param.WriteToDb(cntx); err != nil {
logger.Errorw(ctx, "Mvlan profile write to DB failed", log.Fields{"ProfileName": param.Name})
}
-
}
if _, ok := param.Groups[common.StaticGroup]; ok {
param.Groups[common.StaticGroup].IsStatic = true
@@ -124,10 +123,9 @@
return nil
}
-//This function modifyies the old Igmp Group data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old Igmp Group data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateIgmpGroups(cntx context.Context, hash string, value interface{}) error {
-
ig := value.(*IgmpGroup)
logger.Infow(ctx, "Group Data Migration", log.Fields{"ig": ig, "GroupAddr": ig.GroupAddr, "hash": hash})
if ig.GroupAddr == nil {
@@ -140,8 +138,8 @@
return nil
}
-//This function modifyies the old Igmp Device data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old Igmp Device data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateIgmpDevices(cntx context.Context, hash string, value interface{}) error {
igd := value.(*IgmpGroupDevice)
logger.Infow(ctx, "Group Device Migration", log.Fields{"igd": igd, "GroupAddr": igd.GroupAddr, "hash": hash})
@@ -150,14 +148,14 @@
}
if err := igd.WriteToDb(cntx); err != nil {
logger.Errorw(ctx, "Igmp group device Write to DB failed", log.Fields{"Device": igd.Device,
- "GroupName": igd.GroupName, "GroupAddr": igd.GroupAddr.String()})
+ "GroupName": igd.GroupName, "GroupAddr": igd.GroupAddr.String()})
}
return nil
}
-//This function modifyies the old Igmp Profile data as per current version requirement and also
-//returns the new path on which the modified data has to be written
+// This function modifyies the old Igmp Profile data as per current version requirement and also
+// returns the new path on which the modified data has to be written
func updateIgmpProfiles(cntx context.Context, hash string, value interface{}) error {
igmpProfile := value.(*IgmpProfile)
logger.Infow(ctx, "IGMP Profile Migration", log.Fields{"igmpProfile": igmpProfile, "hash": hash})
@@ -165,7 +163,6 @@
}
func (ig *IgmpGroup) migrateIgmpDevices(cntx context.Context) {
-
devices, _ := db.GetPrevIgmpDevices(cntx, ig.Mvlan, ig.GroupName)
logger.Infow(ctx, "Migratable Devices", log.Fields{"Devices": devices})
for _, device := range devices {
@@ -192,11 +189,9 @@
}
func (igd *IgmpGroupDevice) migrateIgmpChannels(cntx context.Context) {
-
channels, _ := db.GetPrevIgmpChannels(cntx, igd.GroupName, igd.Device)
logger.Infow(ctx, "Migratable Channels", log.Fields{"Channels": channels})
for _, channel := range channels {
-
b, ok := channel.Value.([]byte)
if !ok {
logger.Warn(ctx, "The value type is not []byte")
@@ -220,11 +215,9 @@
}
func (igc *IgmpGroupChannel) migrateIgmpPorts(cntx context.Context) {
-
ports, _ := db.GetPrevIgmpRcvrs(cntx, igc.GroupAddr, igc.Device)
logger.Infow(ctx, "Migratable Ports", log.Fields{"Ports": ports})
for _, port := range ports {
-
b, ok := port.Value.([]byte)
if !ok {
logger.Warn(ctx, "The value type is not []byte")