summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShelley-BaoYue <baoyue2@huawei.com>2023-08-18 15:14:34 +0800
committerShelley-BaoYue <baoyue2@huawei.com>2023-08-21 21:13:46 +0800
commit833346c40013fca6224534c573fd84c7e38bda4b (patch)
treeef9847cf9c0faa9deb36e7d986db6867ecc9b1a5
parentupdate go version to 1.19 (diff)
downloadkubeedge-833346c40013fca6224534c573fd84c7e38bda4b.tar.gz
fix lint
Signed-off-by: Shelley-BaoYue <baoyue2@huawei.com>
-rw-r--r--cloud/cmd/controllermanager/app/controllermanager.go1
-rw-r--r--cloud/pkg/admissioncontroller/admission.go4
-rw-r--r--cloud/pkg/cloudhub/common/model/types.go4
-rw-r--r--cloud/pkg/cloudhub/common/testing/test_framework.go12
-rw-r--r--cloud/pkg/edgecontroller/manager/location.go2
-rw-r--r--cloud/pkg/router/router.go4
-rw-r--r--common/types/types.go2
-rw-r--r--edge/pkg/common/dbm/db.go1
-rw-r--r--edge/pkg/common/message/message.go4
-rw-r--r--edge/pkg/common/util/config.go6
-rw-r--r--edge/pkg/devicetwin/devicetwin.go2
-rw-r--r--edge/pkg/devicetwin/dtclient/device_db.go14
-rw-r--r--edge/pkg/devicetwin/dtclient/deviceattr_db.go16
-rw-r--r--edge/pkg/devicetwin/dtclient/devicetwin_db.go14
-rw-r--r--edge/pkg/devicetwin/dtcommon/util.go6
-rw-r--r--edge/pkg/devicetwin/dtcontext/dtcontext.go22
-rw-r--r--edge/pkg/devicetwin/dtcontext/dtcontext_test.go18
-rw-r--r--edge/pkg/devicetwin/dtmanager/communicate.go4
-rw-r--r--edge/pkg/devicetwin/dtmanager/device.go8
-rw-r--r--edge/pkg/devicetwin/dtmanager/dmiworker.go4
-rw-r--r--edge/pkg/devicetwin/dtmanager/dtworker.go6
-rw-r--r--edge/pkg/devicetwin/dtmanager/membership.go6
-rw-r--r--edge/pkg/devicetwin/dtmanager/twin.go14
-rw-r--r--edge/pkg/devicetwin/dtmodule/dtmodule.go4
-rw-r--r--edge/pkg/devicetwin/dttype/message.go6
-rw-r--r--edge/pkg/devicetwin/dttype/types.go50
-rw-r--r--edge/pkg/devicetwin/dttype/types_helper.go44
-rw-r--r--edge/pkg/devicetwin/dttype/types_test.go2
-rw-r--r--edge/pkg/devicetwin/process.go6
-rw-r--r--edge/pkg/edgehub/clients/adapter.go2
-rw-r--r--edge/pkg/edgehub/clients/factory.go2
-rw-r--r--edge/pkg/edgehub/edgehub.go11
-rw-r--r--edge/pkg/edgehub/process_test.go12
-rw-r--r--edge/pkg/eventbus/common/util/common_test.go10
-rw-r--r--edge/pkg/eventbus/mqtt/server.go2
-rw-r--r--edge/pkg/metamanager/client/nodestatus.go4
-rw-r--r--edge/pkg/metamanager/client/podstatus.go4
-rw-r--r--edge/pkg/metamanager/dao/meta.go2
-rw-r--r--edge/pkg/metamanager/dao/v2/metav2.go2
-rw-r--r--edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/imitator/imitator.go2
-rw-r--r--edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/store.go2
-rw-r--r--edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/watcher.go2
-rw-r--r--edge/pkg/servicebus/dao/targeturls.go2
-rw-r--r--edge/pkg/servicebus/dao/targeturls_test.go2
-rw-r--r--edge/test/integration/appdeployment/application_suite_test.go4
-rw-r--r--edge/test/integration/appdeployment/application_test.go2
-rw-r--r--edge/test/integration/device/device_suite_test.go6
-rwxr-xr-xedge/test/integration/device/device_test.go4
-rwxr-xr-xedge/test/integration/utils/common/log.go10
-rwxr-xr-xedge/test/integration/utils/edge/config.go12
-rwxr-xr-xedge/test/integration/utils/edge/testcontext.go4
-rw-r--r--edge/test/integration/utils/helpers/helpers.go26
-rw-r--r--edge/test/test.go6
-rw-r--r--keadm/cmd/keadm/app/cmd/common/config.go2
-rw-r--r--keadm/cmd/keadm/app/cmd/common/types.go18
-rw-r--r--keadm/cmd/keadm/app/cmd/deprecated/init.go4
-rw-r--r--keadm/cmd/keadm/app/cmd/deprecated/join.go4
-rw-r--r--keadm/cmd/keadm/app/cmd/util/exec.go2
-rw-r--r--keadm/cmd/keadm/app/cmd/util/k8sinstaller.go14
-rw-r--r--keadm/cmd/keadm/app/cmd/util/mqttinstaller.go8
-rw-r--r--keadm/cmd/keadm/app/keadm.go2
-rw-r--r--manifests/manifests.go2
-rw-r--r--pkg/metaserver/key.go12
-rw-r--r--pkg/util/util.go4
-rw-r--r--staging/src/github.com/kubeedge/beehive/pkg/core/model/message.go2
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go2
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go2
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_source.go2
-rw-r--r--staging/src/github.com/kubeedge/viaduct/pkg/cmgr/connmgr.go20
-rw-r--r--tests/e2e/utils/config.go3
-rw-r--r--tests/e2e/utils/context.go7
-rw-r--r--tests/e2e/utils/log.go13
-rw-r--r--tests/e2e/utils/node.go14
-rw-r--r--tests/e2e_edgesite/edgesite_test.go2
-rw-r--r--tests/e2e_keadm/keadm_test.go2
75 files changed, 280 insertions, 282 deletions
diff --git a/cloud/cmd/controllermanager/app/controllermanager.go b/cloud/cmd/controllermanager/app/controllermanager.go
index 527fea5e8..65d006815 100644
--- a/cloud/cmd/controllermanager/app/controllermanager.go
+++ b/cloud/cmd/controllermanager/app/controllermanager.go
@@ -9,7 +9,6 @@ import (
"k8s.io/component-base/cli/globalflag"
"k8s.io/klog/v2"
controllerruntime "sigs.k8s.io/controller-runtime"
-
// set --kubeconfig option
_ "sigs.k8s.io/controller-runtime/pkg/client/config"
diff --git a/cloud/pkg/admissioncontroller/admission.go b/cloud/pkg/admissioncontroller/admission.go
index 7cbf5c3c1..2dbc1ebc5 100644
--- a/cloud/pkg/admissioncontroller/admission.go
+++ b/cloud/pkg/admissioncontroller/admission.go
@@ -44,8 +44,8 @@ const (
var scheme = runtime.NewScheme()
-//codecs is for retrieving serializers for the supported wire formats
-//and conversion wrappers to define preferred internal and external versions.
+// codecs is for retrieving serializers for the supported wire formats
+// and conversion wrappers to define preferred internal and external versions.
var codecs = serializer.NewCodecFactory(scheme)
var controller = &AdmissionController{}
diff --git a/cloud/pkg/cloudhub/common/model/types.go b/cloud/pkg/cloudhub/common/model/types.go
index 59b1bdb1a..64f9fdd90 100644
--- a/cloud/pkg/cloudhub/common/model/types.go
+++ b/cloud/pkg/cloudhub/common/model/types.go
@@ -1,9 +1,7 @@
package model
import (
-
- // Mapping value of json to struct member
- _ "encoding/json"
+ _ "encoding/json" // Mapping value of json to struct member
"fmt"
"strings"
diff --git a/cloud/pkg/cloudhub/common/testing/test_framework.go b/cloud/pkg/cloudhub/common/testing/test_framework.go
index ea78779f2..3e24e09af 100644
--- a/cloud/pkg/cloudhub/common/testing/test_framework.go
+++ b/cloud/pkg/cloudhub/common/testing/test_framework.go
@@ -81,12 +81,12 @@ var ErrVersionConflict = errors.New("VersionError")
// ObjectSyncReactor is a core.Reactor that simulates etcd and API server. It
// stores:
-// - Latest version of objectSyncs saved by the session.
-// - Optionally, list of error that should be returned by reactor, simulating
-// etcd / API server failures. These errors are evaluated in order and every
-// error is returned only once. I.e. when the reactor finds matching
-// ReactorError, it return appropriate error and removes the ReactorError from
-// the list.
+// - Latest version of objectSyncs saved by the session.
+// - Optionally, list of error that should be returned by reactor, simulating
+// etcd / API server failures. These errors are evaluated in order and every
+// error is returned only once. I.e. when the reactor finds matching
+// ReactorError, it return appropriate error and removes the ReactorError from
+// the list.
type ObjectSyncReactor struct {
objectSyncs map[string]*v1alpha1.ObjectSync
lock sync.RWMutex
diff --git a/cloud/pkg/edgecontroller/manager/location.go b/cloud/pkg/edgecontroller/manager/location.go
index 096c3fb20..dc286fc29 100644
--- a/cloud/pkg/edgecontroller/manager/location.go
+++ b/cloud/pkg/edgecontroller/manager/location.go
@@ -131,7 +131,7 @@ func (lc *LocationCache) SecretNodes(namespace, name string) (nodes []string) {
return
}
-//IsEdgeNode checks weather node is edge node or not
+// IsEdgeNode checks weather node is edge node or not
func (lc *LocationCache) IsEdgeNode(nodeName string) bool {
_, ok := lc.EdgeNodes.Load(nodeName)
return ok
diff --git a/cloud/pkg/router/router.go b/cloud/pkg/router/router.go
index 79d42894c..5322a990a 100644
--- a/cloud/pkg/router/router.go
+++ b/cloud/pkg/router/router.go
@@ -7,16 +7,12 @@ import (
"github.com/kubeedge/kubeedge/cloud/pkg/common/modules"
routerconfig "github.com/kubeedge/kubeedge/cloud/pkg/router/config"
"github.com/kubeedge/kubeedge/cloud/pkg/router/listener"
-
// init eventbus
_ "github.com/kubeedge/kubeedge/cloud/pkg/router/provider/eventbus"
-
// init rest
_ "github.com/kubeedge/kubeedge/cloud/pkg/router/provider/rest"
-
// init servicebus
_ "github.com/kubeedge/kubeedge/cloud/pkg/router/provider/servicebus"
-
// init rule
_ "github.com/kubeedge/kubeedge/cloud/pkg/router/rule"
"github.com/kubeedge/kubeedge/pkg/apis/componentconfig/cloudcore/v1alpha1"
diff --git a/common/types/types.go b/common/types/types.go
index 4fe163a68..33a709bff 100644
--- a/common/types/types.go
+++ b/common/types/types.go
@@ -14,7 +14,7 @@ type PodStatusRequest struct {
Status v1.PodStatus
}
-//ExtendResource is the extended resource detail that comes from edge
+// ExtendResource is the extended resource detail that comes from edge
type ExtendResource struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
diff --git a/edge/pkg/common/dbm/db.go b/edge/pkg/common/dbm/db.go
index bf20b52ab..f9b647778 100644
--- a/edge/pkg/common/dbm/db.go
+++ b/edge/pkg/common/dbm/db.go
@@ -4,7 +4,6 @@ import (
"sync"
"github.com/astaxie/beego/orm"
-
//Blank import to run only the init function
_ "github.com/mattn/go-sqlite3"
"k8s.io/klog/v2"
diff --git a/edge/pkg/common/message/message.go b/edge/pkg/common/message/message.go
index 624845321..af06d61e3 100644
--- a/edge/pkg/common/message/message.go
+++ b/edge/pkg/common/message/message.go
@@ -4,7 +4,7 @@ import (
"github.com/kubeedge/beehive/pkg/core/model"
)
-//constant defining node connection types
+// constant defining node connection types
const (
ResourceTypeNodeConnection = "node/connection"
SourceNodeConnection = "edgehub"
@@ -23,7 +23,7 @@ const (
UserGroupName = "user"
)
-//BuildMsg returns message object with router and content details
+// BuildMsg returns message object with router and content details
func BuildMsg(group, parentID, sourceName, resource, operation string, content interface{}) *model.Message {
msg := model.NewMessage(parentID).BuildRouter(sourceName, group, resource, operation).FillBody(content)
return msg
diff --git a/edge/pkg/common/util/config.go b/edge/pkg/common/util/config.go
index db3cea6a1..0c08d54f9 100644
--- a/edge/pkg/common/util/config.go
+++ b/edge/pkg/common/util/config.go
@@ -30,8 +30,8 @@ import (
"k8s.io/klog/v2"
)
-//GenerateTestCertificate generates fake certificates and stores them at the path specified.
-//It accepts 3 arguments path, certFileName and keyFileName
+// GenerateTestCertificate generates fake certificates and stores them at the path specified.
+// It accepts 3 arguments path, certFileName and keyFileName
// "path" is the directory path at which the directory is to be created,
// "certFileName" & "keyFileName" refers to the name of the file to be created without the extension
func GenerateTestCertificate(path string, certFileName string, keyFileName string) error {
@@ -84,7 +84,7 @@ func GenerateTestCertificate(path string, certFileName string, keyFileName strin
return nil
}
-//createPEMfile() creates an encoded file at the path given, with PEM Block specified
+// createPEMfile() creates an encoded file at the path given, with PEM Block specified
func createPEMfile(path string, pemBlock pem.Block) error {
// this will create plain text PEM file.
file, err := os.Create(path)
diff --git a/edge/pkg/devicetwin/devicetwin.go b/edge/pkg/devicetwin/devicetwin.go
index a75b422a6..1fb43e510 100644
--- a/edge/pkg/devicetwin/devicetwin.go
+++ b/edge/pkg/devicetwin/devicetwin.go
@@ -12,7 +12,7 @@ import (
"github.com/kubeedge/kubeedge/pkg/apis/componentconfig/edgecore/v1alpha2"
)
-//DeviceTwin the module
+// DeviceTwin the module
type DeviceTwin struct {
HeartBeatToModule map[string]chan interface{}
DTContexts *dtcontext.DTContext
diff --git a/edge/pkg/devicetwin/dtclient/device_db.go b/edge/pkg/devicetwin/dtclient/device_db.go
index ef6ceeefe..65227595e 100644
--- a/edge/pkg/devicetwin/dtclient/device_db.go
+++ b/edge/pkg/devicetwin/dtclient/device_db.go
@@ -7,7 +7,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/dbm"
)
-//Device the struct of device
+// Device the struct of device
type Device struct {
ID string `orm:"column(id); size(64); pk"`
Name string `orm:"column(name); null; type(text)"`
@@ -16,14 +16,14 @@ type Device struct {
LastOnline string `orm:"column(last_online); null; type(text)"`
}
-//SaveDevice save device
+// SaveDevice save device
func SaveDevice(obm orm.Ormer, doc *Device) error {
num, err := obm.Insert(doc)
klog.V(4).Infof("Insert affected Num: %d, %v", num, err)
return err
}
-//DeleteDeviceByID delete device by id
+// DeleteDeviceByID delete device by id
func DeleteDeviceByID(obm orm.Ormer, id string) error {
num, err := obm.QueryTable(DeviceTableName).Filter("id", id).Delete()
if err != nil {
@@ -68,13 +68,13 @@ func QueryDeviceAll() (*[]Device, error) {
return devices, nil
}
-//DeviceUpdate the struct for updating device
+// DeviceUpdate the struct for updating device
type DeviceUpdate struct {
DeviceID string
Cols map[string]interface{}
}
-//UpdateDeviceMulti update device multi
+// UpdateDeviceMulti update device multi
func UpdateDeviceMulti(updates []DeviceUpdate) error {
var err error
for _, update := range updates {
@@ -86,7 +86,7 @@ func UpdateDeviceMulti(updates []DeviceUpdate) error {
return nil
}
-//AddDeviceTrans the transaction of add device
+// AddDeviceTrans the transaction of add device
func AddDeviceTrans(adds []Device, addAttrs []DeviceAttr, addTwins []DeviceTwin) error {
obm := dbm.DefaultOrmFunc()
err := obm.Begin()
@@ -132,7 +132,7 @@ func AddDeviceTrans(adds []Device, addAttrs []DeviceAttr, addTwins []DeviceTwin)
return err
}
-//DeleteDeviceTrans the transaction of delete device
+// DeleteDeviceTrans the transaction of delete device
func DeleteDeviceTrans(deletes []string) error {
obm := dbm.DefaultOrmFunc()
err := obm.Begin()
diff --git a/edge/pkg/devicetwin/dtclient/deviceattr_db.go b/edge/pkg/devicetwin/dtclient/deviceattr_db.go
index 5636ab7d7..9ad6d1d03 100644
--- a/edge/pkg/devicetwin/dtclient/deviceattr_db.go
+++ b/edge/pkg/devicetwin/dtclient/deviceattr_db.go
@@ -7,7 +7,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/dbm"
)
-//DeviceAttr the struct of device attributes
+// DeviceAttr the struct of device attributes
type DeviceAttr struct {
ID int64 `orm:"column(id);size(64);auto;pk"`
DeviceID string `orm:"column(deviceid); null; type(text)"`
@@ -19,14 +19,14 @@ type DeviceAttr struct {
Metadata string `orm:"column(metadata);null;type(text)"`
}
-//SaveDeviceAttr save device attributes
+// SaveDeviceAttr save device attributes
func SaveDeviceAttr(obm orm.Ormer, doc *DeviceAttr) error {
num, err := obm.Insert(doc)
klog.V(4).Infof("Insert affected Num: %d, %s", num, err)
return err
}
-//DeleteDeviceAttrByDeviceID delete device attr
+// DeleteDeviceAttrByDeviceID delete device attr
func DeleteDeviceAttrByDeviceID(obm orm.Ormer, deviceID string) error {
num, err := obm.QueryTable(DeviceAttrTableName).Filter("deviceid", deviceID).Delete()
if err != nil {
@@ -37,7 +37,7 @@ func DeleteDeviceAttrByDeviceID(obm orm.Ormer, deviceID string) error {
return nil
}
-//DeleteDeviceAttr delete device attr
+// DeleteDeviceAttr delete device attr
func DeleteDeviceAttr(obm orm.Ormer, deviceID string, name string) error {
num, err := obm.QueryTable(DeviceAttrTableName).Filter("deviceid", deviceID).Filter("name", name).Delete()
if err != nil {
@@ -72,20 +72,20 @@ func QueryDeviceAttr(key string, condition string) (*[]DeviceAttr, error) {
return attrs, nil
}
-//DeviceDelete the struct for deleting device
+// DeviceDelete the struct for deleting device
type DeviceDelete struct {
DeviceID string
Name string
}
-//DeviceAttrUpdate the struct for updating device attr
+// DeviceAttrUpdate the struct for updating device attr
type DeviceAttrUpdate struct {
DeviceID string
Name string
Cols map[string]interface{}
}
-//UpdateDeviceAttrMulti update device attr multi
+// UpdateDeviceAttrMulti update device attr multi
func UpdateDeviceAttrMulti(updates []DeviceAttrUpdate) error {
var err error
for _, update := range updates {
@@ -97,7 +97,7 @@ func UpdateDeviceAttrMulti(updates []DeviceAttrUpdate) error {
return nil
}
-//DeviceAttrTrans transaction of device attr
+// DeviceAttrTrans transaction of device attr
func DeviceAttrTrans(adds []DeviceAttr, deletes []DeviceDelete, updates []DeviceAttrUpdate) error {
obm := dbm.DefaultOrmFunc()
err := obm.Begin()
diff --git a/edge/pkg/devicetwin/dtclient/devicetwin_db.go b/edge/pkg/devicetwin/dtclient/devicetwin_db.go
index efed21125..014a32cc5 100644
--- a/edge/pkg/devicetwin/dtclient/devicetwin_db.go
+++ b/edge/pkg/devicetwin/dtclient/devicetwin_db.go
@@ -7,7 +7,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/dbm"
)
-//DeviceTwin the struct of device twin
+// DeviceTwin the struct of device twin
type DeviceTwin struct {
ID int64 `orm:"column(id);size(64);auto;pk"`
DeviceID string `orm:"column(deviceid); null; type(text)"`
@@ -24,14 +24,14 @@ type DeviceTwin struct {
Metadata string `orm:"column(metadata);null;type(text)"`
}
-//SaveDeviceTwin save device twin
+// SaveDeviceTwin save device twin
func SaveDeviceTwin(obm orm.Ormer, doc *DeviceTwin) error {
num, err := obm.Insert(doc)
klog.V(4).Infof("Insert affected Num: %d, %s", num, err)
return err
}
-//DeleteDeviceTwinByDeviceID delete device twin
+// DeleteDeviceTwinByDeviceID delete device twin
func DeleteDeviceTwinByDeviceID(obm orm.Ormer, deviceID string) error {
num, err := obm.QueryTable(DeviceTwinTableName).Filter("deviceid", deviceID).Delete()
if err != nil {
@@ -42,7 +42,7 @@ func DeleteDeviceTwinByDeviceID(obm orm.Ormer, deviceID string) error {
return nil
}
-//DeleteDeviceTwin delete device twin
+// DeleteDeviceTwin delete device twin
func DeleteDeviceTwin(obm orm.Ormer, deviceID string, name string) error {
num, err := obm.QueryTable(DeviceTwinTableName).Filter("deviceid", deviceID).Filter("name", name).Delete()
if err != nil {
@@ -77,14 +77,14 @@ func QueryDeviceTwin(key string, condition string) (*[]DeviceTwin, error) {
return twin, nil
}
-//DeviceTwinUpdate the struct for updating device twin
+// DeviceTwinUpdate the struct for updating device twin
type DeviceTwinUpdate struct {
DeviceID string
Name string
Cols map[string]interface{}
}
-//UpdateDeviceTwinMulti update device twin multi
+// UpdateDeviceTwinMulti update device twin multi
func UpdateDeviceTwinMulti(updates []DeviceTwinUpdate) error {
var err error
for _, update := range updates {
@@ -96,7 +96,7 @@ func UpdateDeviceTwinMulti(updates []DeviceTwinUpdate) error {
return nil
}
-//DeviceTwinTrans transaction of device twin
+// DeviceTwinTrans transaction of device twin
func DeviceTwinTrans(adds []DeviceTwin, deletes []DeviceDelete, updates []DeviceTwinUpdate) error {
obm := dbm.DefaultOrmFunc()
err := obm.Begin()
diff --git a/edge/pkg/devicetwin/dtcommon/util.go b/edge/pkg/devicetwin/dtcommon/util.go
index 4ed477f32..2adb4d373 100644
--- a/edge/pkg/devicetwin/dtcommon/util.go
+++ b/edge/pkg/devicetwin/dtcommon/util.go
@@ -15,7 +15,7 @@ import (
pb "github.com/kubeedge/kubeedge/pkg/apis/dmi/v1alpha1"
)
-//ValidateValue validate value type
+// ValidateValue validate value type
func ValidateValue(valueType string, value string) error {
switch valueType {
case "":
@@ -47,14 +47,14 @@ func ValidateValue(valueType string, value string) error {
}
}
-//ValidateTwinKey validate twin key
+// ValidateTwinKey validate twin key
func ValidateTwinKey(key string) bool {
pattern := "^[a-zA-Z0-9-_.,:/@#]{1,128}$"
match, _ := regexp.MatchString(pattern, key)
return match
}
-//ValidateTwinValue validate twin value
+// ValidateTwinValue validate twin value
func ValidateTwinValue(value string) bool {
pattern := "^[a-zA-Z0-9-_.,:/@#]{1,512}$"
match, _ := regexp.MatchString(pattern, value)
diff --git a/edge/pkg/devicetwin/dtcontext/dtcontext.go b/edge/pkg/devicetwin/dtcontext/dtcontext.go
index b6427d794..0b3d7f9f0 100644
--- a/edge/pkg/devicetwin/dtcontext/dtcontext.go
+++ b/edge/pkg/devicetwin/dtcontext/dtcontext.go
@@ -16,7 +16,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dttype"
)
-//DTContext context for devicetwin
+// DTContext context for devicetwin
type DTContext struct {
GroupID string
NodeName string
@@ -32,7 +32,7 @@ type DTContext struct {
State string
}
-//InitDTContext init dtcontext
+// InitDTContext init dtcontext
func InitDTContext() (*DTContext, error) {
return &DTContext{
GroupID: "",
@@ -48,7 +48,7 @@ func InitDTContext() (*DTContext, error) {
}, nil
}
-//CommTo communicate
+// CommTo communicate
func (dtc *DTContext) CommTo(dtmName string, content interface{}) error {
if v, exist := dtc.CommChan[dtmName]; exist {
v <- content
@@ -57,7 +57,7 @@ func (dtc *DTContext) CommTo(dtmName string, content interface{}) error {
return errors.New("Not found chan to communicate")
}
-//HeartBeat heartbeat to dtcontroller
+// HeartBeat heartbeat to dtcontroller
func (dtc *DTContext) HeartBeat(dtmName string, content interface{}) error {
if strings.Compare(content.(string), "ping") == 0 {
dtc.ModulesHealth.Store(dtmName, time.Now().Unix())
@@ -69,7 +69,7 @@ func (dtc *DTContext) HeartBeat(dtmName string, content interface{}) error {
return nil
}
-//GetMutex get mutex
+// GetMutex get mutex
func (dtc *DTContext) GetMutex(deviceID string) (*sync.Mutex, bool) {
v, mutexExist := dtc.DeviceMutex.Load(deviceID)
if !mutexExist {
@@ -83,7 +83,7 @@ func (dtc *DTContext) GetMutex(deviceID string) (*sync.Mutex, bool) {
return nil, false
}
-//Lock get the lock of the device
+// Lock get the lock of the device
func (dtc *DTContext) Lock(deviceID string) bool {
deviceMutex, ok := dtc.GetMutex(deviceID)
if ok {
@@ -94,7 +94,7 @@ func (dtc *DTContext) Lock(deviceID string) bool {
return false
}
-//Unlock remove the lock of the device
+// Unlock remove the lock of the device
func (dtc *DTContext) Unlock(deviceID string) bool {
deviceMutex, ok := dtc.GetMutex(deviceID)
if ok {
@@ -115,13 +115,13 @@ func (dtc *DTContext) UnlockAll() {
dtc.Mutex.Unlock()
}
-//IsDeviceExist judge device is exist
+// IsDeviceExist judge device is exist
func (dtc *DTContext) IsDeviceExist(deviceID string) bool {
_, ok := dtc.DeviceList.Load(deviceID)
return ok
}
-//GetDevice get device
+// GetDevice get device
func (dtc *DTContext) GetDevice(deviceID string) (*dttype.Device, bool) {
d, ok := dtc.DeviceList.Load(deviceID)
if ok {
@@ -133,7 +133,7 @@ func (dtc *DTContext) GetDevice(deviceID string) (*dttype.Device, bool) {
return nil, false
}
-//Send send result
+// Send send result
func (dtc *DTContext) Send(identity string, action string, module string, msg *model.Message) error {
dtMsg := &dttype.DTMessage{
Action: action,
@@ -143,7 +143,7 @@ func (dtc *DTContext) Send(identity string, action string, module string, msg *m
return dtc.CommTo(module, dtMsg)
}
-//BuildModelMessage build mode messages
+// BuildModelMessage build mode messages
func (dtc *DTContext) BuildModelMessage(group string, parentID string, resource string, operation string, content interface{}) *model.Message {
msg := model.NewMessage(parentID)
msg.BuildRouter(modules.TwinGroup, group, resource, operation)
diff --git a/edge/pkg/devicetwin/dtcontext/dtcontext_test.go b/edge/pkg/devicetwin/dtcontext/dtcontext_test.go
index e356026be..a7d7db504 100644
--- a/edge/pkg/devicetwin/dtcontext/dtcontext_test.go
+++ b/edge/pkg/devicetwin/dtcontext/dtcontext_test.go
@@ -29,7 +29,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/testutil"
)
-//TestCommTo is function to test CommTo().
+// TestCommTo is function to test CommTo().
func TestCommTo(t *testing.T) {
commChan := make(map[string]chan interface{})
testInterface := make(chan interface{}, 1)
@@ -79,7 +79,7 @@ func TestCommTo(t *testing.T) {
}
}
-//TestHeartBeat is function to test HeartBeat().
+// TestHeartBeat is function to test HeartBeat().
func TestHeartBeat(t *testing.T) {
tests := []struct {
name string
@@ -121,7 +121,7 @@ func TestHeartBeat(t *testing.T) {
}
}
-//TestGetMutex is function to test GetMutex().
+// TestGetMutex is function to test GetMutex().
func TestGetMutex(t *testing.T) {
dtc := &DTContext{
DeviceMutex: &sync.Map{},
@@ -169,7 +169,7 @@ func TestGetMutex(t *testing.T) {
}
}
-//TestLock is function to test Lock().
+// TestLock is function to test Lock().
func TestLock(t *testing.T) {
dtc := &DTContext{
Mutex: &sync.RWMutex{},
@@ -204,7 +204,7 @@ func TestLock(t *testing.T) {
}
}
-//TestUnlock is function to test Unlock().
+// TestUnlock is function to test Unlock().
func TestUnlock(t *testing.T) {
dtc := &DTContext{
Mutex: &sync.RWMutex{},
@@ -241,7 +241,7 @@ func TestUnlock(t *testing.T) {
}
}
-//TestIsDeviceExist is to test IsDeviceExist().
+// TestIsDeviceExist is to test IsDeviceExist().
func TestIsDeviceExist(t *testing.T) {
dtc := &DTContext{
DeviceList: &sync.Map{},
@@ -274,7 +274,7 @@ func TestIsDeviceExist(t *testing.T) {
}
}
-//Function TestGetDevice is to test GetDevice().
+// Function TestGetDevice is to test GetDevice().
func TestGetDevice(t *testing.T) {
dtc := &DTContext{
DeviceList: &sync.Map{},
@@ -325,7 +325,7 @@ func TestGetDevice(t *testing.T) {
}
}
-//Function TestSend is function to test Send().
+// Function TestSend is function to test Send().
func TestSend(t *testing.T) {
content := testutil.GenerateAddDevicePalyloadMsg(t)
commChan := make(map[string]chan interface{})
@@ -371,7 +371,7 @@ func TestSend(t *testing.T) {
}
}
-//TestBuildModelMessage is to test BuildModelMessage().
+// TestBuildModelMessage is to test BuildModelMessage().
func TestBuildModelMessage(t *testing.T) {
dtc := &DTContext{}
content := testutil.GenerateAddDevicePalyloadMsg(t)
diff --git a/edge/pkg/devicetwin/dtmanager/communicate.go b/edge/pkg/devicetwin/dtmanager/communicate.go
index 0413b3273..7a9af4426 100644
--- a/edge/pkg/devicetwin/dtmanager/communicate.go
+++ b/edge/pkg/devicetwin/dtmanager/communicate.go
@@ -27,13 +27,13 @@ func init() {
initActionCallBack()
}
-//CommWorker deal app response event
+// CommWorker deal app response event
type CommWorker struct {
Worker
Group string
}
-//Start worker
+// Start worker
func (cw CommWorker) Start() {
for {
select {
diff --git a/edge/pkg/devicetwin/dtmanager/device.go b/edge/pkg/devicetwin/dtmanager/device.go
index f48ebfb89..bf57daf8e 100644
--- a/edge/pkg/devicetwin/dtmanager/device.go
+++ b/edge/pkg/devicetwin/dtmanager/device.go
@@ -23,13 +23,13 @@ var (
deviceActionCallBack map[string]CallBack
)
-//DeviceWorker deal device event
+// DeviceWorker deal device event
type DeviceWorker struct {
Worker
Group string
}
-//Start worker
+// Start worker
func (dw DeviceWorker) Start() {
initDeviceActionCallBack()
for {
@@ -151,7 +151,7 @@ func dealDeviceAttrUpdate(context *dtcontext.DTContext, resource string, msg int
return nil
}
-//UpdateDeviceAttr update device attributes
+// UpdateDeviceAttr update device attributes
func UpdateDeviceAttr(context *dtcontext.DTContext, deviceID string, attributes map[string]*dttype.MsgAttr, baseMessage dttype.BaseMessage, dealType int) (interface{}, error) {
klog.Infof("Begin to update attributes of the device %s", deviceID)
var err error
@@ -198,7 +198,7 @@ func UpdateDeviceAttr(context *dtcontext.DTContext, deviceID string, attributes
return nil, nil
}
-//DealMsgAttr get diff,0:update, 1:detail
+// DealMsgAttr get diff,0:update, 1:detail
func DealMsgAttr(context *dtcontext.DTContext, deviceID string, msgAttrs map[string]*dttype.MsgAttr, dealType int) dttype.DealAttrResult {
device, ok := context.GetDevice(deviceID)
if !ok {
diff --git a/edge/pkg/devicetwin/dtmanager/dmiworker.go b/edge/pkg/devicetwin/dtmanager/dmiworker.go
index 13e8f5c29..435e9e179 100644
--- a/edge/pkg/devicetwin/dtmanager/dmiworker.go
+++ b/edge/pkg/devicetwin/dtmanager/dmiworker.go
@@ -37,7 +37,7 @@ import (
pb "github.com/kubeedge/kubeedge/pkg/apis/dmi/v1alpha1"
)
-//TwinWorker deal twin event
+// TwinWorker deal twin event
type DMIWorker struct {
Worker
Group string
@@ -62,7 +62,7 @@ func (dw *DMIWorker) init() {
dw.initDeviceMapperInfoFromDB()
}
-//Start worker
+// Start worker
func (dw DMIWorker) Start() {
klog.Infoln("dmi worker start")
dw.init()
diff --git a/edge/pkg/devicetwin/dtmanager/dtworker.go b/edge/pkg/devicetwin/dtmanager/dtworker.go
index 4c900bf8c..6e362b010 100644
--- a/edge/pkg/devicetwin/dtmanager/dtworker.go
+++ b/edge/pkg/devicetwin/dtmanager/dtworker.go
@@ -2,12 +2,12 @@ package dtmanager
import "github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtcontext"
-//DTWorker worker for devicetwin
+// DTWorker worker for devicetwin
type DTWorker interface {
Start()
}
-//Worker actual
+// Worker actual
type Worker struct {
ReceiverChan chan interface{}
ConfirmChan chan interface{}
@@ -15,5 +15,5 @@ type Worker struct {
DTContexts *dtcontext.DTContext
}
-//CallBack for deal
+// CallBack for deal
type CallBack func(*dtcontext.DTContext, string, interface{}) error
diff --git a/edge/pkg/devicetwin/dtmanager/membership.go b/edge/pkg/devicetwin/dtmanager/membership.go
index 10b821341..a4775a279 100644
--- a/edge/pkg/devicetwin/dtmanager/membership.go
+++ b/edge/pkg/devicetwin/dtmanager/membership.go
@@ -23,13 +23,13 @@ var (
memActionCallBack map[string]CallBack
)
-//MemWorker deal membership event
+// MemWorker deal membership event
type MemWorker struct {
Worker
Group string
}
-//Start worker
+// Start worker
func (mw MemWorker) Start() {
initMemActionCallBack()
for {
@@ -358,7 +358,7 @@ func dealMembershipGetInner(context *dtcontext.DTContext, payload []byte) error
return nil
}
-//SyncDeviceFromSqlite sync device from sqlite
+// SyncDeviceFromSqlite sync device from sqlite
func SyncDeviceFromSqlite(context *dtcontext.DTContext, deviceID string) error {
klog.Infof("Sync device detail info from DB of device %s", deviceID)
_, exist := context.GetDevice(deviceID)
diff --git a/edge/pkg/devicetwin/dtmanager/twin.go b/edge/pkg/devicetwin/dtmanager/twin.go
index 6495be6c9..8027d008f 100644
--- a/edge/pkg/devicetwin/dtmanager/twin.go
+++ b/edge/pkg/devicetwin/dtmanager/twin.go
@@ -42,13 +42,13 @@ var (
initTwinActionCallBackOnce sync.Once
)
-//TwinWorker deal twin event
+// TwinWorker deal twin event
type TwinWorker struct {
Worker
Group string
}
-//Start worker
+// Start worker
func (tw TwinWorker) Start() {
initTwinActionCallBack()
for {
@@ -164,7 +164,7 @@ func Updated(context *dtcontext.DTContext, deviceID string, payload []byte) {
DealDeviceTwin(context, deviceID, eventID, msg.Twin, RestDealType)
}
-//DealDeviceTwin deal device twin
+// DealDeviceTwin deal device twin
func DealDeviceTwin(context *dtcontext.DTContext, deviceID string, eventID string, msgTwin map[string]*dttype.MsgTwin, dealType int) error {
klog.Infof("Begin to deal device twin of the device %s", deviceID)
now := time.Now().UnixNano() / 1e6
@@ -229,7 +229,7 @@ func DealDeviceTwin(context *dtcontext.DTContext, deviceID string, eventID strin
return nil
}
-//dealUpdateResult build update result and send result, if success send the current state
+// dealUpdateResult build update result and send result, if success send the current state
func dealUpdateResult(context *dtcontext.DTContext, deviceID string, eventID string, code int, err error, payload []byte) error {
klog.Infof("Deal update result of device %s: Build and send result", deviceID)
@@ -278,7 +278,7 @@ func dealSyncResult(context *dtcontext.DTContext, deviceID string, baseMessage d
context.BuildModelMessage("resource", "", resource, model.UpdateOperation, dttype.DeviceTwinResult{BaseMessage: baseMessage, Twin: twin}))
}
-//dealDocument build document and save current state as last state, update sqlite
+// dealDocument build document and save current state as last state, update sqlite
func dealDocument(context *dtcontext.DTContext, deviceID string, baseMessage dttype.BaseMessage, twinDocument map[string]*dttype.TwinDoc) error {
klog.Infof("Deal document of device %s: build and send document", deviceID)
payload, _ := dttype.BuildDeviceTwinDocument(baseMessage, twinDocument)
@@ -344,7 +344,7 @@ func DealGetTwin(context *dtcontext.DTContext, deviceID string, payload []byte)
context.BuildModelMessage(modules.BusGroup, "", topic, messagepkg.OperationPublish, msg))
}
-//dealtype 0:update ,2:cloud_update,1:detail result,3:deleted
+// dealtype 0:update ,2:cloud_update,1:detail result,3:deleted
func dealVersion(version *dttype.TwinVersion, reqVersion *dttype.TwinVersion, dealType int) (bool, error) {
if dealType == RestDealType {
version.EdgeVersion = version.EdgeVersion + 1
@@ -904,7 +904,7 @@ func dealTwinAdd(returnResult *dttype.DealTwinResult, deviceID string, key strin
return nil
}
-//DealMsgTwin get diff while updating twin
+// DealMsgTwin get diff while updating twin
func DealMsgTwin(context *dtcontext.DTContext, deviceID string, msgTwins map[string]*dttype.MsgTwin, dealType int) dttype.DealTwinResult {
add := make([]dtclient.DeviceTwin, 0)
deletes := make([]dtclient.DeviceDelete, 0)
diff --git a/edge/pkg/devicetwin/dtmodule/dtmodule.go b/edge/pkg/devicetwin/dtmodule/dtmodule.go
index e1ec2616e..67eed0e37 100644
--- a/edge/pkg/devicetwin/dtmodule/dtmodule.go
+++ b/edge/pkg/devicetwin/dtmodule/dtmodule.go
@@ -8,7 +8,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtmanager"
)
-//DTModule module for devicetwin
+// DTModule module for devicetwin
type DTModule struct {
Name string
Worker dtmanager.DTWorker
@@ -56,7 +56,7 @@ func (dm *DTModule) InitWorker(recv chan interface{}, confirm chan interface{},
}
}
-//Start module, actual worker start
+// Start module, actual worker start
func (dm DTModule) Start() {
defer func() {
if err := recover(); err != nil {
diff --git a/edge/pkg/devicetwin/dttype/message.go b/edge/pkg/devicetwin/dttype/message.go
index 2b2e77633..cf6fca783 100644
--- a/edge/pkg/devicetwin/dttype/message.go
+++ b/edge/pkg/devicetwin/dttype/message.go
@@ -4,14 +4,14 @@ import (
"github.com/kubeedge/beehive/pkg/core/model"
)
-//MsgSubPub the struct of message for subscribe or publish
+// MsgSubPub the struct of message for subscribe or publish
type MsgSubPub struct {
Action string `json:"action"`
Payload string `json:"payload"`
Qos int `json:"qos"`
}
-//DTMessage the struct of message for communicating between cloud and edge
+// DTMessage the struct of message for communicating between cloud and edge
type DTMessage struct {
Msg *model.Message
Identity string
@@ -19,7 +19,7 @@ type DTMessage struct {
Type string
}
-//GetDetailNode the info existed in req body
+// GetDetailNode the info existed in req body
type GetDetailNode struct {
EventType string `json:"event_type,omitempty"`
EventID string `json:"event_id,omitempty"`
diff --git a/edge/pkg/devicetwin/dttype/types.go b/edge/pkg/devicetwin/dttype/types.go
index 7094f8835..372c1e535 100644
--- a/edge/pkg/devicetwin/dttype/types.go
+++ b/edge/pkg/devicetwin/dttype/types.go
@@ -12,7 +12,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtcommon"
)
-//Device the struct of device
+// Device the struct of device
type Device struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
@@ -23,7 +23,7 @@ type Device struct {
Twin map[string]*MsgTwin `json:"twin,omitempty"`
}
-//BaseMessage the base struct of event message
+// BaseMessage the base struct of event message
type BaseMessage struct {
EventID string `json:"event_id"`
Timestamp int64 `json:"timestamp"`
@@ -34,12 +34,12 @@ var ErrorUpdate = errors.New("Update twin error, key:twin does not exist")
var ErrorKey = errors.New("The key of twin must only include upper or lowercase letters, number, english, and special letter - _ . , : / @ # and the length of key should be less than 128 bytes")
var ErrorValue = errors.New("The value of twin must only include upper or lowercase letters, number, english, and special letter - _ . , : / @ # and the length of value should be less than 512 bytes")
-//SetEventID set event id
+// SetEventID set event id
func (bs *BaseMessage) SetEventID(eventID string) {
bs.EventID = eventID
}
-//BuildBaseMessage build base msg
+// BuildBaseMessage build base msg
func BuildBaseMessage() BaseMessage {
now := time.Now().UnixNano() / 1e6
return BaseMessage{
@@ -47,7 +47,7 @@ func BuildBaseMessage() BaseMessage {
Timestamp: now}
}
-//Parameter container para
+// Parameter container para
type Parameter struct {
EventID string
Code int
@@ -61,20 +61,20 @@ type Result struct {
Reason string `json:"reason,omitempty"`
}
-//MembershipDetail the struct of membership detail
+// MembershipDetail the struct of membership detail
type MembershipDetail struct {
BaseMessage
Devices []Device `json:"devices"`
}
-//MembershipUpdate the struct of membership update
+// MembershipUpdate the struct of membership update
type MembershipUpdate struct {
BaseMessage
AddDevices []Device `json:"added_devices"`
RemoveDevices []Device `json:"removed_devices"`
}
-//MarshalMembershipUpdate marshal membership update
+// MarshalMembershipUpdate marshal membership update
func MarshalMembershipUpdate(result MembershipUpdate) ([]byte, error) {
for i := range result.AddDevices {
if result.AddDevices[i].Twin != nil {
@@ -102,14 +102,14 @@ func MarshalMembershipUpdate(result MembershipUpdate) ([]byte, error) {
return resultJSON, err
}
-//MsgAttr the struct of device attr
+// MsgAttr the struct of device attr
type MsgAttr struct {
Value string `json:"value"`
Optional *bool `json:"optional,omitempty"`
Metadata *TypeMetadata `json:"metadata,omitempty"`
}
-//MsgTwin the struct of device twin
+// MsgTwin the struct of device twin
type MsgTwin struct {
Expected *TwinValue `json:"expected,omitempty"`
Actual *TwinValue `json:"actual,omitempty"`
@@ -119,44 +119,44 @@ type MsgTwin struct {
ActualVersion *TwinVersion `json:"actual_version,omitempty"`
}
-//TwinValue the struct of twin value
+// TwinValue the struct of twin value
type TwinValue struct {
Value *string `json:"value,omitempty"`
Metadata *ValueMetadata `json:"metadata,omitempty"`
}
-//TwinVersion twin version
+// TwinVersion twin version
type TwinVersion struct {
CloudVersion int64 `json:"cloud"`
EdgeVersion int64 `json:"edge"`
}
-//TypeMetadata the meta of value type
+// TypeMetadata the meta of value type
type TypeMetadata struct {
Type string `json:"type,omitempty"`
}
-//ValueMetadata the meta of value
+// ValueMetadata the meta of value
type ValueMetadata struct {
Timestamp int64 `json:"timestamp,omitempty"`
}
-//UpdateCloudVersion update cloud version
+// UpdateCloudVersion update cloud version
func (tv *TwinVersion) UpdateCloudVersion() {
tv.CloudVersion = tv.CloudVersion + 1
}
-//UpdateEdgeVersion update edge version while dealing edge update
+// UpdateEdgeVersion update edge version while dealing edge update
func (tv *TwinVersion) UpdateEdgeVersion() {
tv.EdgeVersion = tv.EdgeVersion + 1
}
-//CompareWithCloud compare with cloud vershon while dealing cloud update req
+// CompareWithCloud compare with cloud vershon while dealing cloud update req
func (tv TwinVersion) CompareWithCloud(tvCloud TwinVersion) bool {
return tvCloud.EdgeVersion >= tv.EdgeVersion
}
-//UpdateCloudVersion update cloud version
+// UpdateCloudVersion update cloud version
func UpdateCloudVersion(version string) (string, error) {
var twinversion TwinVersion
err := json.Unmarshal([]byte(version), &twinversion)
@@ -171,7 +171,7 @@ func UpdateCloudVersion(version string) (string, error) {
return string(result), nil
}
-//UpdateEdgeVersion update Edge version
+// UpdateEdgeVersion update Edge version
func UpdateEdgeVersion(version string) (string, error) {
var twinversion TwinVersion
err := json.Unmarshal([]byte(version), &twinversion)
@@ -186,7 +186,7 @@ func UpdateEdgeVersion(version string) (string, error) {
return string(result), nil
}
-//CompareVersion compare cloud version
+// CompareVersion compare cloud version
func CompareVersion(cloudversion string, edgeversion string) bool {
var twincloudversion TwinVersion
err := json.Unmarshal([]byte(cloudversion), &twincloudversion)
@@ -217,19 +217,19 @@ func UnmarshalConnectedInfo(payload []byte) (ConnectedInfo, error) {
return connectedInfo, nil
}
-//DeviceTwinDocument the struct of twin document
+// DeviceTwinDocument the struct of twin document
type DeviceTwinDocument struct {
BaseMessage
Twin map[string]*TwinDoc `json:"twin"`
}
-//TwinDoc the struct of twin document
+// TwinDoc the struct of twin document
type TwinDoc struct {
LastState *MsgTwin `json:"last"`
CurrentState *MsgTwin `json:"current"`
}
-//DeviceTwinUpdate the struct of device twin update
+// DeviceTwinUpdate the struct of device twin update
type DeviceTwinUpdate struct {
BaseMessage
Twin map[string]*MsgTwin `json:"twin"`
@@ -286,7 +286,7 @@ func UnmarshalDeviceTwinUpdate(payload []byte) (*DeviceTwinUpdate, error) {
return &deviceTwinUpdate, nil
}
-//DealTwinResult the result of dealing twin
+// DealTwinResult the result of dealing twin
type DealTwinResult struct {
Add []dtclient.DeviceTwin
Delete []dtclient.DeviceDelete
@@ -297,7 +297,7 @@ type DealTwinResult struct {
Err error
}
-//DealAttrResult the result of dealing attr
+// DealAttrResult the result of dealing attr
type DealAttrResult struct {
Add []dtclient.DeviceAttr
Delete []dtclient.DeviceDelete
diff --git a/edge/pkg/devicetwin/dttype/types_helper.go b/edge/pkg/devicetwin/dttype/types_helper.go
index a74414615..dd3357972 100644
--- a/edge/pkg/devicetwin/dttype/types_helper.go
+++ b/edge/pkg/devicetwin/dttype/types_helper.go
@@ -9,7 +9,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtcommon"
)
-//UnmarshalMembershipDetail Unmarshal membershipdetail
+// UnmarshalMembershipDetail Unmarshal membershipdetail
func UnmarshalMembershipDetail(payload []byte) (*MembershipDetail, error) {
var membershipDetail MembershipDetail
err := json.Unmarshal(payload, &membershipDetail)
@@ -19,7 +19,7 @@ func UnmarshalMembershipDetail(payload []byte) (*MembershipDetail, error) {
return &membershipDetail, nil
}
-//UnmarshalMembershipUpdate Unmarshal membershipupdate
+// UnmarshalMembershipUpdate Unmarshal membershipupdate
func UnmarshalMembershipUpdate(payload []byte) (*MembershipUpdate, error) {
var membershipUpdate MembershipUpdate
err := json.Unmarshal(payload, &membershipUpdate)
@@ -29,7 +29,7 @@ func UnmarshalMembershipUpdate(payload []byte) (*MembershipUpdate, error) {
return &membershipUpdate, nil
}
-//UnmarshalBaseMessage Unmarshal get
+// UnmarshalBaseMessage Unmarshal get
func UnmarshalBaseMessage(payload []byte) (*BaseMessage, error) {
var get BaseMessage
err := json.Unmarshal(payload, &get)
@@ -39,7 +39,7 @@ func UnmarshalBaseMessage(payload []byte) (*BaseMessage, error) {
return &get, nil
}
-//DeviceAttrToMsgAttr deviceattr to msgattr
+// DeviceAttrToMsgAttr deviceattr to msgattr
func DeviceAttrToMsgAttr(deviceAttrs []dtclient.DeviceAttr) map[string]*MsgAttr {
msgAttrs := make(map[string]*MsgAttr, len(deviceAttrs))
for _, attr := range deviceAttrs {
@@ -52,7 +52,7 @@ func DeviceAttrToMsgAttr(deviceAttrs []dtclient.DeviceAttr) map[string]*MsgAttr
return msgAttrs
}
-//DeviceTwinToMsgTwin devicetwin contains meta and version to msgtwin,
+// DeviceTwinToMsgTwin devicetwin contains meta and version to msgtwin,
func DeviceTwinToMsgTwin(deviceTwins []dtclient.DeviceTwin) map[string]*MsgTwin {
msgTwins := make(map[string]*MsgTwin, len(deviceTwins))
for _, twin := range deviceTwins {
@@ -98,7 +98,7 @@ func DeviceTwinToMsgTwin(deviceTwins []dtclient.DeviceTwin) map[string]*MsgTwin
return msgTwins
}
-//MsgAttrToDeviceAttr msgattr to deviceattr
+// MsgAttrToDeviceAttr msgattr to deviceattr
func MsgAttrToDeviceAttr(name string, msgAttr *MsgAttr) dtclient.DeviceAttr {
attrType := "string"
if msgAttr.Metadata != nil {
@@ -114,7 +114,7 @@ func MsgAttrToDeviceAttr(name string, msgAttr *MsgAttr) dtclient.DeviceAttr {
Optional: optional}
}
-//CopyMsgTwin copy msg twin
+// CopyMsgTwin copy msg twin
func CopyMsgTwin(msgTwin *MsgTwin, noVersion bool) MsgTwin {
var result MsgTwin
payload, _ := json.Marshal(msgTwin)
@@ -126,7 +126,7 @@ func CopyMsgTwin(msgTwin *MsgTwin, noVersion bool) MsgTwin {
return result
}
-//CopyMsgAttr copy msg attr
+// CopyMsgAttr copy msg attr
func CopyMsgAttr(msgAttr *MsgAttr) MsgAttr {
var result MsgAttr
payload, _ := json.Marshal(msgAttr)
@@ -134,7 +134,7 @@ func CopyMsgAttr(msgAttr *MsgAttr) MsgAttr {
return result
}
-//MsgTwinToDeviceTwin msgtwin convert to devicetwin
+// MsgTwinToDeviceTwin msgtwin convert to devicetwin
func MsgTwinToDeviceTwin(name string, msgTwin *MsgTwin) dtclient.DeviceTwin {
optional := true
if msgTwin.Optional != nil {
@@ -150,13 +150,13 @@ func MsgTwinToDeviceTwin(name string, msgTwin *MsgTwin) dtclient.DeviceTwin {
Optional: optional}
}
-//DeviceMsg the struct of device state msg
+// DeviceMsg the struct of device state msg
type DeviceMsg struct {
BaseMessage
Device Device `json:"device"`
}
-//BuildDeviceState build the msg
+// BuildDeviceState build the msg
func BuildDeviceState(baseMessage BaseMessage, device Device) ([]byte, error) {
result := DeviceMsg{
BaseMessage: baseMessage,
@@ -171,13 +171,13 @@ func BuildDeviceState(baseMessage BaseMessage, device Device) ([]byte, error) {
return payload, nil
}
-//DeviceAttrUpdate the struct of device attr update msg
+// DeviceAttrUpdate the struct of device attr update msg
type DeviceAttrUpdate struct {
BaseMessage
Attributes map[string]*MsgAttr `json:"attributes"`
}
-//BuildDeviceAttrUpdate build the DeviceAttrUpdate
+// BuildDeviceAttrUpdate build the DeviceAttrUpdate
func BuildDeviceAttrUpdate(baseMessage BaseMessage, attrs map[string]*MsgAttr) ([]byte, error) {
result := DeviceAttrUpdate{BaseMessage: baseMessage, Attributes: attrs}
payload, err := json.Marshal(result)
@@ -187,13 +187,13 @@ func BuildDeviceAttrUpdate(baseMessage BaseMessage, attrs map[string]*MsgAttr) (
return payload, nil
}
-//MembershipGetResult membership get result
+// MembershipGetResult membership get result
type MembershipGetResult struct {
BaseMessage
Devices []Device `json:"devices"`
}
-//BuildMembershipGetResult build memebership
+// BuildMembershipGetResult build memebership
func BuildMembershipGetResult(baseMessage BaseMessage, devices []*Device) ([]byte, error) {
result := make([]Device, 0, len(devices))
for _, v := range devices {
@@ -212,13 +212,13 @@ func BuildMembershipGetResult(baseMessage BaseMessage, devices []*Device) ([]byt
return payload, nil
}
-//DeviceTwinResult device get result
+// DeviceTwinResult device get result
type DeviceTwinResult struct {
BaseMessage
Twin map[string]*MsgTwin `json:"twin"`
}
-//BuildDeviceTwinResult build device twin result, 0:get,1:update,2:sync
+// BuildDeviceTwinResult build device twin result, 0:get,1:update,2:sync
func BuildDeviceTwinResult(baseMessage BaseMessage, twins map[string]*MsgTwin, dealType int) ([]byte, error) {
result := make(map[string]*MsgTwin)
if dealType == 0 {
@@ -260,14 +260,14 @@ func BuildErrorResult(para Parameter) ([]byte, error) {
return errorResult, nil
}
-//DeviceUpdate device update
+// DeviceUpdate device update
type DeviceUpdate struct {
BaseMessage
State string `json:"state,omitempty"`
Attributes map[string]*MsgAttr `json:"attributes"`
}
-//UnmarshalDeviceUpdate unmarshal device update
+// UnmarshalDeviceUpdate unmarshal device update
func UnmarshalDeviceUpdate(payload []byte) (*DeviceUpdate, error) {
var get DeviceUpdate
err := json.Unmarshal(payload, &get)
@@ -277,14 +277,14 @@ func UnmarshalDeviceUpdate(payload []byte) (*DeviceUpdate, error) {
return &get, nil
}
-//DeviceTwinDelta devicetwin
+// DeviceTwinDelta devicetwin
type DeviceTwinDelta struct {
BaseMessage
Twin map[string]*MsgTwin `json:"twin"`
Delta map[string]string `json:"delta"`
}
-//BuildDeviceTwinDelta build device twin delta
+// BuildDeviceTwinDelta build device twin delta
func BuildDeviceTwinDelta(baseMessage BaseMessage, twins map[string]*MsgTwin) ([]byte, bool) {
result := make(map[string]*MsgTwin, len(twins))
delta := make(map[string]string)
@@ -323,7 +323,7 @@ func BuildDeviceTwinDelta(baseMessage BaseMessage, twins map[string]*MsgTwin) ([
return payload, false
}
-//BuildDeviceTwinDocument build device twin document
+// BuildDeviceTwinDocument build device twin document
func BuildDeviceTwinDocument(baseMessage BaseMessage, twins map[string]*TwinDoc) ([]byte, bool) {
payload, err := json.Marshal(DeviceTwinDocument{BaseMessage: baseMessage, Twin: twins})
if err != nil {
diff --git a/edge/pkg/devicetwin/dttype/types_test.go b/edge/pkg/devicetwin/dttype/types_test.go
index 17142a67c..55b075c51 100644
--- a/edge/pkg/devicetwin/dttype/types_test.go
+++ b/edge/pkg/devicetwin/dttype/types_test.go
@@ -267,7 +267,7 @@ func TestCompareWithCloud(t *testing.T) {
}
}
-//TestUpdateCloudVersion tests UpdateCloudVersion().
+// TestUpdateCloudVersion tests UpdateCloudVersion().
func TestUpdateCloudVersion(t *testing.T) {
twinVersion := TwinVersion{CloudVersion: 1}
bytesTwinVersion, _ := json.Marshal(twinVersion)
diff --git a/edge/pkg/devicetwin/process.go b/edge/pkg/devicetwin/process.go
index f6ab34e99..a5da28b17 100644
--- a/edge/pkg/devicetwin/process.go
+++ b/edge/pkg/devicetwin/process.go
@@ -27,7 +27,7 @@ var (
ActionModuleMap map[string]string
)
-//RegisterDTModule register dtmodule
+// RegisterDTModule register dtmodule
func (dt *DeviceTwin) RegisterDTModule(name string) {
module := dtmodule.DTModule{
Name: name,
@@ -40,7 +40,7 @@ func (dt *DeviceTwin) RegisterDTModule(name string) {
dt.DTModules[name] = module
}
-//distributeMsg distribute message to diff module
+// distributeMsg distribute message to diff module
func (dt *DeviceTwin) distributeMsg(m interface{}) error {
msg, ok := m.(model.Message)
if !ok {
@@ -133,7 +133,7 @@ func SyncSqlite(context *dtcontext.DTContext) error {
return nil
}
-//SyncDeviceFromSqlite sync device from sqlite
+// SyncDeviceFromSqlite sync device from sqlite
func SyncDeviceFromSqlite(context *dtcontext.DTContext, deviceID string) error {
klog.Infof("Sync device detail info from DB of device %s", deviceID)
_, exist := context.GetDevice(deviceID)
diff --git a/edge/pkg/edgehub/clients/adapter.go b/edge/pkg/edgehub/clients/adapter.go
index bc00a5f6c..a089dd7c7 100644
--- a/edge/pkg/edgehub/clients/adapter.go
+++ b/edge/pkg/edgehub/clients/adapter.go
@@ -4,7 +4,7 @@ import (
"github.com/kubeedge/beehive/pkg/core/model"
)
-//Adapter is a web socket client interface
+// Adapter is a web socket client interface
type Adapter interface {
Init() error
UnInit()
diff --git a/edge/pkg/edgehub/clients/factory.go b/edge/pkg/edgehub/clients/factory.go
index 6a70b1f75..d087ad13c 100644
--- a/edge/pkg/edgehub/clients/factory.go
+++ b/edge/pkg/edgehub/clients/factory.go
@@ -9,7 +9,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/edgehub/config"
)
-//GetClient returns an Adapter object with new web socket
+// GetClient returns an Adapter object with new web socket
func GetClient() (Adapter, error) {
config := config.Config
switch {
diff --git a/edge/pkg/edgehub/edgehub.go b/edge/pkg/edgehub/edgehub.go
index 0f9f62f38..2498d07f2 100644
--- a/edge/pkg/edgehub/edgehub.go
+++ b/edge/pkg/edgehub/edgehub.go
@@ -13,13 +13,12 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/edgehub/certificate"
"github.com/kubeedge/kubeedge/edge/pkg/edgehub/clients"
"github.com/kubeedge/kubeedge/edge/pkg/edgehub/config"
-
// register Upgrade handler
_ "github.com/kubeedge/kubeedge/edge/pkg/edgehub/upgrade"
"github.com/kubeedge/kubeedge/pkg/apis/componentconfig/edgecore/v1alpha2"
)
-//EdgeHub defines edgehub object structure
+// EdgeHub defines edgehub object structure
type EdgeHub struct {
certManager certificate.CertManager
chClient clients.Adapter
@@ -61,22 +60,22 @@ func Register(eh *v1alpha2.EdgeHub, nodeName string) {
core.Register(newEdgeHub(eh.Enable))
}
-//Name returns the name of EdgeHub module
+// Name returns the name of EdgeHub module
func (eh *EdgeHub) Name() string {
return modules.EdgeHubModuleName
}
-//Group returns EdgeHub group
+// Group returns EdgeHub group
func (eh *EdgeHub) Group() string {
return modules.HubGroup
}
-//Enable indicates whether this module is enabled
+// Enable indicates whether this module is enabled
func (eh *EdgeHub) Enable() bool {
return eh.enable
}
-//Start sets context and starts the controller
+// Start sets context and starts the controller
func (eh *EdgeHub) Start() {
eh.certManager = certificate.NewCertManager(config.Config.EdgeHub, config.Config.NodeName)
eh.certManager.Start()
diff --git a/edge/pkg/edgehub/process_test.go b/edge/pkg/edgehub/process_test.go
index ca298f8a0..167f1aee4 100644
--- a/edge/pkg/edgehub/process_test.go
+++ b/edge/pkg/edgehub/process_test.go
@@ -46,7 +46,7 @@ func init() {
beehiveContext.AddModuleGroup(module.EdgeHubModuleName, module.EdgeHubModuleName)
}
-//TestIsSyncResponse() tests whether there exists a channel with the given message_id in the syncKeeper
+// TestIsSyncResponse() tests whether there exists a channel with the given message_id in the syncKeeper
func TestIsSyncResponse(t *testing.T) {
tests := []struct {
name string
@@ -76,7 +76,7 @@ func TestIsSyncResponse(t *testing.T) {
}
}
-//TestDispatch() tests whether the messages are properly dispatched to their respective modules
+// TestDispatch() tests whether the messages are properly dispatched to their respective modules
func TestDispatch(t *testing.T) {
tests := []struct {
name string
@@ -117,7 +117,7 @@ func TestDispatch(t *testing.T) {
}
}
-//TestRouteToEdge() is used to test whether the message received from websocket is dispatched to the required modules
+// TestRouteToEdge() is used to test whether the message received from websocket is dispatched to the required modules
func TestRouteToEdge(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
@@ -155,7 +155,7 @@ func TestRouteToEdge(t *testing.T) {
}
}
-//TestSendToCloud() tests whether the send to cloud functionality works properly
+// TestSendToCloud() tests whether the send to cloud functionality works properly
func TestSendToCloud(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
@@ -214,7 +214,7 @@ func TestSendToCloud(t *testing.T) {
}
}
-//TestRouteToCloud() tests the reception of the message from the beehive framework and forwarding of that message to cloud
+// TestRouteToCloud() tests the reception of the message from the beehive framework and forwarding of that message to cloud
func TestRouteToCloud(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
@@ -252,7 +252,7 @@ func TestRouteToCloud(t *testing.T) {
}
}
-//TestKeepalive() tests whether ping message sent to the cloud at regular intervals happens properly
+// TestKeepalive() tests whether ping message sent to the cloud at regular intervals happens properly
func TestKeepalive(t *testing.T) {
CertFile := "/tmp/kubeedge/certs/edge.crt"
KeyFile := "/tmp/kubeedge/certs/edge.key"
diff --git a/edge/pkg/eventbus/common/util/common_test.go b/edge/pkg/eventbus/common/util/common_test.go
index 6300dc700..7a5be874a 100644
--- a/edge/pkg/eventbus/common/util/common_test.go
+++ b/edge/pkg/eventbus/common/util/common_test.go
@@ -41,7 +41,7 @@ func init() {
eventconfig.InitConfigure(cfg.Modules.EventBus, nodeName)
}
-//TestCheckKeyExist checks the functionality of CheckKeyExist function
+// TestCheckKeyExist checks the functionality of CheckKeyExist function
func TestCheckKeyExist(t *testing.T) {
tests := []struct {
name string
@@ -72,7 +72,7 @@ func TestCheckKeyExist(t *testing.T) {
}
}
-//TestCheckClientToken checks client token received
+// TestCheckClientToken checks client token received
func TestCheckClientToken(t *testing.T) {
tests := []struct {
name string
@@ -101,7 +101,7 @@ func TestCheckClientToken(t *testing.T) {
}
}
-//TestPathExist checks the functionality of PathExist function
+// TestPathExist checks the functionality of PathExist function
func TestPathExist(t *testing.T) {
tests := []struct {
name string
@@ -128,7 +128,7 @@ func TestPathExist(t *testing.T) {
}
}
-//TestHubClientInit checks the HubClientInit method that it returns the same clientOptions object or not
+// TestHubClientInit checks the HubClientInit method that it returns the same clientOptions object or not
func TestHubClientInit(t *testing.T) {
tests := []struct {
name string
@@ -184,7 +184,7 @@ func TestHubClientInit(t *testing.T) {
}
}
-//TestLoopConnect checks LoopConnect to connect to MQTT broker
+// TestLoopConnect checks LoopConnect to connect to MQTT broker
func TestLoopConnect(t *testing.T) {
tests := []struct {
name string
diff --git a/edge/pkg/eventbus/mqtt/server.go b/edge/pkg/eventbus/mqtt/server.go
index 07073691d..ae6907012 100644
--- a/edge/pkg/eventbus/mqtt/server.go
+++ b/edge/pkg/eventbus/mqtt/server.go
@@ -26,7 +26,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/eventbus/dao"
)
-//Server serve as an internal mqtt broker.
+// Server serve as an internal mqtt broker.
type Server struct {
// Internal mqtt url
url string
diff --git a/edge/pkg/metamanager/client/nodestatus.go b/edge/pkg/metamanager/client/nodestatus.go
index 2f7eda187..a12be6ad6 100644
--- a/edge/pkg/metamanager/client/nodestatus.go
+++ b/edge/pkg/metamanager/client/nodestatus.go
@@ -9,12 +9,12 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/modules"
)
-//NodeStatusGetter is interface to get node status
+// NodeStatusGetter is interface to get node status
type NodeStatusGetter interface {
NodeStatus(namespace string) NodeStatusInterface
}
-//NodeStatusInterface is node status interface
+// NodeStatusInterface is node status interface
type NodeStatusInterface interface {
Create(*edgeapi.NodeStatusRequest) (*edgeapi.NodeStatusRequest, error)
Update(rsName string, ns edgeapi.NodeStatusRequest) error
diff --git a/edge/pkg/metamanager/client/podstatus.go b/edge/pkg/metamanager/client/podstatus.go
index 5378518d3..12ad680b0 100644
--- a/edge/pkg/metamanager/client/podstatus.go
+++ b/edge/pkg/metamanager/client/podstatus.go
@@ -10,12 +10,12 @@ import (
commodule "github.com/kubeedge/kubeedge/edge/pkg/common/modules"
)
-//PodStatusGetter is interface to get pod status
+// PodStatusGetter is interface to get pod status
type PodStatusGetter interface {
PodStatus(namespace string) PodStatusInterface
}
-//PodStatusInterface is interface of pod status
+// PodStatusInterface is interface of pod status
type PodStatusInterface interface {
Create(*edgeapi.PodStatusRequest) (*edgeapi.PodStatusRequest, error)
Update(rsName string, ps edgeapi.PodStatusRequest) error
diff --git a/edge/pkg/metamanager/dao/meta.go b/edge/pkg/metamanager/dao/meta.go
index 93d1ad8ce..37fdbab71 100644
--- a/edge/pkg/metamanager/dao/meta.go
+++ b/edge/pkg/metamanager/dao/meta.go
@@ -14,7 +14,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/dbm"
)
-//constant metatable name reference
+// constant metatable name reference
const (
MetaTableName = "meta"
)
diff --git a/edge/pkg/metamanager/dao/v2/metav2.go b/edge/pkg/metamanager/dao/v2/metav2.go
index 4410655d1..91d1a0ed3 100644
--- a/edge/pkg/metamanager/dao/v2/metav2.go
+++ b/edge/pkg/metamanager/dao/v2/metav2.go
@@ -7,7 +7,7 @@ import (
"github.com/kubeedge/kubeedge/edge/pkg/common/dbm"
)
-//constant metatable name reference
+// constant metatable name reference
const (
NewMetaTableName = "meta_v2"
diff --git a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/imitator/imitator.go b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/imitator/imitator.go
index 47c3cc412..04d1be044 100644
--- a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/imitator/imitator.go
+++ b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/imitator/imitator.go
@@ -58,7 +58,7 @@ func (s *imitator) Inject(msg model.Message) {
}
}
-//TODO: filter out insert or update req that the obj's rev is smaller than the stored
+// TODO: filter out insert or update req that the obj's rev is smaller than the stored
func (s *imitator) InsertOrUpdateObj(ctx context.Context, obj runtime.Object) error {
key, err := metaserver.KeyFuncObj(obj)
if err != nil {
diff --git a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/store.go b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/store.go
index 69058ff63..411b33e20 100644
--- a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/store.go
+++ b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/store.go
@@ -22,7 +22,7 @@ import (
)
/*
- This file is designed to encapsulate the Imitator as Store.Interface,
+This file is designed to encapsulate the Imitator as Store.Interface,
*/
type store struct {
client imitator.Client
diff --git a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/watcher.go b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/watcher.go
index 2eee5d3f2..8f3cb9669 100644
--- a/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/watcher.go
+++ b/edge/pkg/metamanager/metaserver/kubernetes/storage/sqlite/watcher.go
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/edge/pkg/servicebus/dao/targeturls.go b/edge/pkg/servicebus/dao/targeturls.go
index 85a029d3f..b8fbf3bc1 100644
--- a/edge/pkg/servicebus/dao/targeturls.go
+++ b/edge/pkg/servicebus/dao/targeturls.go
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/edge/pkg/servicebus/dao/targeturls_test.go b/edge/pkg/servicebus/dao/targeturls_test.go
index faa943582..af46897bd 100644
--- a/edge/pkg/servicebus/dao/targeturls_test.go
+++ b/edge/pkg/servicebus/dao/targeturls_test.go
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/edge/test/integration/appdeployment/application_suite_test.go b/edge/test/integration/appdeployment/application_suite_test.go
index dadd24a3c..b991bd5f6 100644
--- a/edge/test/integration/appdeployment/application_suite_test.go
+++ b/edge/test/integration/appdeployment/application_suite_test.go
@@ -27,13 +27,13 @@ import (
"github.com/kubeedge/kubeedge/edge/test/integration/utils/edge"
)
-//context to load config and access across the package
+// context to load config and access across the package
var (
ctx *edge.TestContext
cfg edge.Config
)
-//Function to run the Ginkgo Test
+// Function to run the Ginkgo Test
func TestEdgecoreAppDeployment(t *testing.T) {
RegisterFailHandler(Fail)
//var UID string
diff --git a/edge/test/integration/appdeployment/application_test.go b/edge/test/integration/appdeployment/application_test.go
index e0a2001fa..4385609ee 100644
--- a/edge/test/integration/appdeployment/application_test.go
+++ b/edge/test/integration/appdeployment/application_test.go
@@ -35,7 +35,7 @@ const (
AppHandler = "/pods"
)
-//Run Test cases
+// Run Test cases
var _ = Describe("Application deployment in edgecore Testing", func() {
var UID string
Context("Test application deployment and delete deployment", func() {
diff --git a/edge/test/integration/device/device_suite_test.go b/edge/test/integration/device/device_suite_test.go
index 3e421cc44..56d2519f6 100644
--- a/edge/test/integration/device/device_suite_test.go
+++ b/edge/test/integration/device/device_suite_test.go
@@ -31,13 +31,13 @@ import (
"github.com/kubeedge/kubeedge/edge/test/integration/utils/helpers"
)
-//context to load config and access across the package
+// context to load config and access across the package
var (
ctx *edge.TestContext
cfg edge.Config
)
-//Interface to validate the MQTT connection.
+// Interface to validate the MQTT connection.
type Token interface {
Wait() bool
WaitTimeout(time.Duration) bool
@@ -63,7 +63,7 @@ var (
ClientID = "eventbus"
)
-//Function to run the Ginkgo Test
+// Function to run the Ginkgo Test
func TestEdgecoreEventBus(t *testing.T) {
RegisterFailHandler(Fail)
var _ = BeforeSuite(func() {
diff --git a/edge/test/integration/device/device_test.go b/edge/test/integration/device/device_test.go
index 23b1bff56..0a0ebefc1 100755
--- a/edge/test/integration/device/device_test.go
+++ b/edge/test/integration/device/device_test.go
@@ -32,7 +32,7 @@ import (
. "github.com/kubeedge/kubeedge/edge/test/integration/utils/helpers"
)
-//Devicestate from subscribed MQTT topic
+// Devicestate from subscribed MQTT topic
var DeviceState string
type DeviceUpdates struct {
@@ -97,7 +97,7 @@ var DeviceATT dttype.Device
var DeviceIDWithTwin string
var DeviceTW dttype.Device
-//Run Test cases
+// Run Test cases
var _ = Describe("Event Bus Testing", func() {
Context("Publish on eventbus topics throgh MQTT internal broker", func() {
BeforeEach(func() {
diff --git a/edge/test/integration/utils/common/log.go b/edge/test/integration/utils/common/log.go
index 18be56712..1bc3a71ea 100755
--- a/edge/test/integration/utils/common/log.go
+++ b/edge/test/integration/utils/common/log.go
@@ -23,30 +23,30 @@ import (
"github.com/onsi/ginkgo"
)
-//Function to get time in millisec
+// nowStamp get time in millisec
func nowStamp() string {
return time.Now().Format(time.StampMilli)
}
-//functiont to log the Ginkgo framework logs
+// logf log the Ginkgo framework logs
func logf(level string, format string, args ...interface{}) {
fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
}
-//Funciton to log Filure logs
+// Fatalf log Failure logs
func Fatalf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("FAIL", msg)
ginkgo.Fail(nowStamp()+": "+msg, 1)
}
-//function for log level
+// Infof for log level
func Infof(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("INFO", msg)
}
-//Function to print the test case name and status of execution
+// PrintTestcaseNameandStatus to print the test case name and status of execution
func PrintTestcaseNameandStatus() {
var Status string
testSpecReport := ginkgo.CurrentGinkgoTestDescription()
diff --git a/edge/test/integration/utils/edge/config.go b/edge/test/integration/utils/edge/config.go
index ad433fa1c..455223898 100755
--- a/edge/test/integration/utils/edge/config.go
+++ b/edge/test/integration/utils/edge/config.go
@@ -26,7 +26,7 @@ import (
"github.com/kubeedge/kubeedge/edge/test/integration/utils/common"
)
-//config.json decode struct
+// config.json decode struct
type Config struct {
MqttEndpoint string `json:"mqttEndpoint"`
TestManager string `json:"testManager"`
@@ -35,10 +35,10 @@ type Config struct {
NodeID string `json:"nodeId"`
}
-//config struct
+// config struct
var config *Config
-//get config.json path
+// get config.json path
func LoadConfig() Config {
if config == nil {
config = loadConfigJSONFromPath()
@@ -46,7 +46,7 @@ func LoadConfig() Config {
return *config
}
-//Load Config.json from the PWD, and decode the config.
+// Load Config.json from the PWD, and decode the config.
func loadConfigJSONFromPath() *Config {
path := getConfigPath()
_, err := filepath.Abs(filepath.Dir(path))
@@ -69,7 +69,7 @@ func loadConfigJSONFromPath() *Config {
return config
}
-//Get config path from Env or hard code the file path
+// Get config path from Env or hard code the file path
func getConfigPath() string {
path := os.Getenv("TESTCONFIG")
if path == "" {
@@ -78,7 +78,7 @@ func getConfigPath() string {
return path
}
-//function to Generate Random string
+// function to Generate Random string
func GetRandomString(length int) string {
str := "-0123456789abcdefghijklmnopqrstuvwxyz"
bytes := []byte(str)
diff --git a/edge/test/integration/utils/edge/testcontext.go b/edge/test/integration/utils/edge/testcontext.go
index 9b4f92260..2c62b3c07 100755
--- a/edge/test/integration/utils/edge/testcontext.go
+++ b/edge/test/integration/utils/edge/testcontext.go
@@ -16,12 +16,12 @@ limitations under the License.
package edge
-//Test context struct
+// Test context struct
type TestContext struct {
Cfg Config
}
-//function to get the testcontext Object.
+// function to get the testcontext Object.
func NewTestContext(cfg Config) *TestContext {
return &TestContext{
Cfg: cfg,
diff --git a/edge/test/integration/utils/helpers/helpers.go b/edge/test/integration/utils/helpers/helpers.go
index 1edf6b4ea..059963025 100644
--- a/edge/test/integration/utils/helpers/helpers.go
+++ b/edge/test/integration/utils/helpers/helpers.go
@@ -37,13 +37,13 @@ import (
"github.com/kubeedge/kubeedge/edge/test/integration/utils/edge"
)
-//DeviceUpdate device update
+// DeviceUpdate device update
type DeviceUpdate struct {
State string `json:"state,omitempty"`
Attributes map[string]*dttype.MsgAttr `json:"attributes"`
}
-//Device the struct of device
+// Device the struct of device
type Device struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
@@ -52,7 +52,7 @@ type Device struct {
LastOnline string `json:"last_online,omitempty"`
}
-//Attribute Structure to read data from DB (Should match with the DB-table 'device_attr' schema)
+// Attribute Structure to read data from DB (Should match with the DB-table 'device_attr' schema)
type Attribute struct {
ID string `json:"id,omitempty"`
DeviceID string `json:"deviceid,omitempty"`
@@ -64,7 +64,7 @@ type Attribute struct {
MetaData string `json:"metadata,omitempty"`
}
-//Twin Structure to read data from DB (Should match with the DB-table 'device_twin' schema)
+// Twin Structure to read data from DB (Should match with the DB-table 'device_twin' schema)
type TwinAttribute struct {
ID string `json:"id,omitempty"`
DeviceID string `json:"deviceid,omitempty"`
@@ -85,7 +85,7 @@ func GenerateDeviceID(deviceSuffix string) string {
return deviceSuffix + edge.GetRandomString(10)
}
-//Function to Generate Device
+// Function to Generate Device
func CreateDevice(deviceID string, deviceName string, deviceState string) dttype.Device {
device := dttype.Device{
ID: deviceID,
@@ -98,7 +98,7 @@ func CreateDevice(deviceID string, deviceName string, deviceState string) dttype
return device
}
-//Function to add Device attribute to existing device
+// Function to add Device attribute to existing device
func AddDeviceAttribute(device dttype.Device, attributeName string, attributeValue string, attributeType string) {
var optional = true
var typeMeta = dttype.TypeMetadata{Type: attributeType}
@@ -106,7 +106,7 @@ func AddDeviceAttribute(device dttype.Device, attributeName string, attributeVal
device.Attributes[attributeName] = &attribute
}
-//Function to add Twin attribute to existing device
+// Function to add Twin attribute to existing device
func AddTwinAttribute(device dttype.Device, attributeName string, attributeValue string, attributeType string) {
value := attributeValue
optional := true
@@ -125,7 +125,7 @@ func AddTwinAttribute(device dttype.Device, attributeName string, attributeValue
device.Twin[attributeName] = &msgTwin
}
-//Function to access the edgecore DB and return the device state.
+// Function to access the edgecore DB and return the device state.
func GetDeviceStateFromDB(deviceID string) string {
var device Device
db, err := sql.Open("sqlite3", utils.DBFile)
@@ -222,7 +222,7 @@ func HubClientInit(server, clientID, username, password string) *MQTT.ClientOpti
return opts
}
-//function to handle device addition and deletion.
+// function to handle device addition and deletion.
func HandleAddAndDeleteDevice(operation, testMgrEndPoint string, device dttype.Device) bool {
var httpMethod string
var payload dttype.MembershipUpdate
@@ -270,7 +270,7 @@ func HandleAddAndDeleteDevice(operation, testMgrEndPoint string, device dttype.D
return true
}
-//HandleAddAndDeletePods is function to handle app deployment/delete deployment.
+// HandleAddAndDeletePods is function to handle app deployment/delete deployment.
func HandleAddAndDeletePods(operation string, edgedpoint string, UID string, container []v1.Container, restartPolicy v1.RestartPolicy) bool {
var httpMethod string
switch operation {
@@ -314,7 +314,7 @@ func HandleAddAndDeletePods(operation string, edgedpoint string, UID string, con
return true
}
-//Function to get the pods from Edged
+// Function to get the pods from Edged
func GetPods(EdgedEndpoint string) (v1.PodList, error) {
var pods v1.PodList
var bytes io.Reader
@@ -346,7 +346,7 @@ func GetPods(EdgedEndpoint string) (v1.PodList, error) {
return pods, nil
}
-//CheckPodRunningState is function to check the Pod state
+// CheckPodRunningState is function to check the Pod state
func CheckPodRunningState(EdgedEndPoint, podname string) {
gomega.Eventually(func() string {
var status string
@@ -362,7 +362,7 @@ func CheckPodRunningState(EdgedEndPoint, podname string) {
}, "240s", "2s").Should(gomega.Equal("Running"), "Application Deployment is Unsuccessful, Pod has not come to Running State")
}
-//CheckPodDeletion is function to check pod deletion
+// CheckPodDeletion is function to check pod deletion
func CheckPodDeletion(EdgedEndPoint, UID string) {
gomega.Eventually(func() bool {
var IsExist = false
diff --git a/edge/test/test.go b/edge/test/test.go
index 446488d98..047403b79 100644
--- a/edge/test/test.go
+++ b/edge/test/test.go
@@ -47,7 +47,7 @@ func (tm *testManager) Enable() bool {
return tm.enable
}
-//Function to get the pods from Edged
+// Function to get the pods from Edged
func GetPodListFromEdged(w http.ResponseWriter) error {
var pods v1.PodList
var bytes io.Reader
@@ -87,7 +87,7 @@ func GetPodListFromEdged(w http.ResponseWriter) error {
return nil
}
-//Function to handle Get/Add/Delete deployment list.
+// Function to handle Get/Add/Delete deployment list.
func (tm *testManager) podHandler(w http.ResponseWriter, req *http.Request) {
var operation string
var p v1.Pod
@@ -127,7 +127,7 @@ func (tm *testManager) podHandler(w http.ResponseWriter, req *http.Request) {
}
}
-//Function to handle device addition and removal from the edgenode
+// Function to handle device addition and removal from the edgenode
func (tm *testManager) deviceHandler(w http.ResponseWriter, req *http.Request) {
var operation string
var Content interface{}
diff --git a/keadm/cmd/keadm/app/cmd/common/config.go b/keadm/cmd/keadm/app/cmd/common/config.go
index a63526896..dc675ef4c 100644
--- a/keadm/cmd/keadm/app/cmd/common/config.go
+++ b/keadm/cmd/keadm/app/cmd/common/config.go
@@ -22,7 +22,7 @@ import (
"sigs.k8s.io/yaml"
)
-//Write2File writes data into a file in path
+// Write2File writes data into a file in path
func Write2File(path string, data interface{}) error {
d, err := yaml.Marshal(data)
if err != nil {
diff --git a/keadm/cmd/keadm/app/cmd/common/types.go b/keadm/cmd/keadm/app/cmd/common/types.go
index 41ab8873c..1c2cf351a 100644
--- a/keadm/cmd/keadm/app/cmd/common/types.go
+++ b/keadm/cmd/keadm/app/cmd/common/types.go
@@ -20,7 +20,7 @@ import (
"github.com/blang/semver"
)
-//InitBaseOptions has the kubeedge cloud deprecated init base information filled by CLI
+// InitBaseOptions has the kubeedge cloud deprecated init base information filled by CLI
type InitBaseOptions struct {
KubeEdgeVersion string
KubeConfig string
@@ -30,7 +30,7 @@ type InitBaseOptions struct {
TarballPath string
}
-//InitOptions has the kubeedge cloud init information filled by CLI
+// InitOptions has the kubeedge cloud init information filled by CLI
type InitOptions struct {
KubeConfig string
KubeEdgeVersion string
@@ -45,7 +45,7 @@ type InitOptions struct {
DryRun bool
}
-//JoinOptions has the kubeedge cloud init information filled by CLI
+// JoinOptions has the kubeedge cloud init information filled by CLI
type JoinOptions struct {
InitBaseOptions
CertPath string
@@ -110,10 +110,10 @@ type DiagnoseObject struct {
Use string
}
-//ModuleRunning is defined to know the running status of KubeEdge components
+// ModuleRunning is defined to know the running status of KubeEdge components
type ModuleRunning uint8
-//Different possible values for ModuleRunning type
+// Different possible values for ModuleRunning type
const (
NoneRunning ModuleRunning = iota
KubeEdgeCloudRunning
@@ -123,7 +123,7 @@ const (
// ComponentType is the type of KubeEdge components, cloudcore or edgecore
type ComponentType string
-//All Component type
+// All Component type
const (
CloudCore ComponentType = "cloudcore"
EdgeCore ComponentType = "edgecore"
@@ -135,13 +135,13 @@ type InstallOptions struct {
TarballPath string
}
-//ToolsInstaller interface for tools with install and teardown methods.
+// ToolsInstaller interface for tools with install and teardown methods.
type ToolsInstaller interface {
InstallTools() error
TearDown() error
}
-//OSTypeInstaller interface for methods to be executed over a specified OS distribution type
+// OSTypeInstaller interface for methods to be executed over a specified OS distribution type
type OSTypeInstaller interface {
InstallMQTT() error
IsK8SComponentInstalled(string, string) error
@@ -152,7 +152,7 @@ type OSTypeInstaller interface {
IsKubeEdgeProcessRunning(string) (bool, error)
}
-//FlagData stores value and default value of the flags used in this command
+// FlagData stores value and default value of the flags used in this command
type FlagData struct {
Val interface{}
DefVal interface{}
diff --git a/keadm/cmd/keadm/app/cmd/deprecated/init.go b/keadm/cmd/keadm/app/cmd/deprecated/init.go
index 3d3e4ff50..5c9754785 100644
--- a/keadm/cmd/keadm/app/cmd/deprecated/init.go
+++ b/keadm/cmd/keadm/app/cmd/deprecated/init.go
@@ -76,7 +76,7 @@ func NewDeprecatedCloudInit() *cobra.Command {
return cmd
}
-//newInitOptions will initialise new instance of options everytime
+// newInitOptions will initialise new instance of options everytime
func newInitOptions() *types.InitBaseOptions {
opts := &types.InitBaseOptions{}
opts.KubeConfig = types.DefaultKubeConfig
@@ -104,7 +104,7 @@ func addInitFlags(cmd *cobra.Command, initOpts *types.InitBaseOptions) {
"Use this key to set the temp directory path for KubeEdge tarball, if not exist, download it")
}
-//Add2CloudToolsList Reads the flagData (containing val and default val) and join options to fill the list of tools.
+// Add2CloudToolsList Reads the flagData (containing val and default val) and join options to fill the list of tools.
func Add2CloudToolsList(toolList map[string]types.ToolsInstaller, flagData map[string]types.FlagData, initOptions *types.InitBaseOptions) error {
var kubeVer string
flgData, ok := flagData[types.KubeEdgeVersion]
diff --git a/keadm/cmd/keadm/app/cmd/deprecated/join.go b/keadm/cmd/keadm/app/cmd/deprecated/join.go
index 8748baf9e..849ed7ac1 100644
--- a/keadm/cmd/keadm/app/cmd/deprecated/join.go
+++ b/keadm/cmd/keadm/app/cmd/deprecated/join.go
@@ -32,7 +32,7 @@ import (
var (
edgeJoinLongDescription = `
-Deprecated:
+Deprecated:
"keadm deprecated join" command bootstraps KubeEdge's worker node (at the edge) component.
It will also connect with cloud component to receive
further instructions and forward telemetry data from
@@ -88,7 +88,7 @@ func newJoinOptions() *types.JoinOptions {
return opts
}
-//Add2EdgeToolsList Reads the flagData (containing val and default val) and join options to fill the list of tools.
+// Add2EdgeToolsList Reads the flagData (containing val and default val) and join options to fill the list of tools.
func Add2EdgeToolsList(toolList map[string]types.ToolsInstaller, flagData map[string]types.FlagData, joinOptions *types.JoinOptions) error {
var kubeVer string
diff --git a/keadm/cmd/keadm/app/cmd/util/exec.go b/keadm/cmd/keadm/app/cmd/util/exec.go
index c91537c6a..718a2e648 100644
--- a/keadm/cmd/keadm/app/cmd/util/exec.go
+++ b/keadm/cmd/keadm/app/cmd/util/exec.go
@@ -9,7 +9,7 @@ import (
"syscall"
)
-//Command defines commands to be executed and captures std out and std error
+// Command defines commands to be executed and captures std out and std error
type Command struct {
Cmd *exec.Cmd
StdOut []byte
diff --git a/keadm/cmd/keadm/app/cmd/util/k8sinstaller.go b/keadm/cmd/keadm/app/cmd/util/k8sinstaller.go
index 0640824b8..329b16f09 100644
--- a/keadm/cmd/keadm/app/cmd/util/k8sinstaller.go
+++ b/keadm/cmd/keadm/app/cmd/util/k8sinstaller.go
@@ -35,15 +35,15 @@ import (
"github.com/kubeedge/kubeedge/common/constants"
)
-//K8SInstTool embeds Common struct and contains the default K8S version and
-//a flag depicting if host is an edge or cloud node
-//It implements ToolsInstaller interface
+// K8SInstTool embeds Common struct and contains the default K8S version and
+// a flag depicting if host is an edge or cloud node
+// It implements ToolsInstaller interface
type K8SInstTool struct {
Common
}
-//InstallTools sets the OS interface, checks if K8S installation is required or not.
-//If required then install the said version.
+// InstallTools sets the OS interface, checks if K8S installation is required or not.
+// If required then install the said version.
func (ks *K8SInstTool) InstallTools() error {
ks.SetOSInterface(GetOSInterface())
@@ -198,8 +198,8 @@ func createKubeEdgeV1CRD(dynamicClient dynamic.Interface, crdFile string) error
return err
}
-//TearDown should uninstall K8S, but it is not required either for cloud or edge node.
-//It is defined so that K8SInstTool implements ToolsInstaller interface
+// TearDown should uninstall K8S, but it is not required either for cloud or edge node.
+// It is defined so that K8SInstTool implements ToolsInstaller interface
func (ks *K8SInstTool) TearDown() error {
return nil
}
diff --git a/keadm/cmd/keadm/app/cmd/util/mqttinstaller.go b/keadm/cmd/keadm/app/cmd/util/mqttinstaller.go
index 3b6f80dea..efc009c83 100644
--- a/keadm/cmd/keadm/app/cmd/util/mqttinstaller.go
+++ b/keadm/cmd/keadm/app/cmd/util/mqttinstaller.go
@@ -16,12 +16,12 @@ limitations under the License.
package util
-//MQTTInstTool embeds Common struct and It implements ToolsInstaller interface
+// MQTTInstTool embeds Common struct and It implements ToolsInstaller interface
type MQTTInstTool struct {
Common
}
-//InstallTools sets the OS interface, it simply installs the said version
+// InstallTools sets the OS interface, it simply installs the said version
func (m *MQTTInstTool) InstallTools() error {
m.SetOSInterface(GetOSInterface())
err := m.InstallMQTT()
@@ -31,8 +31,8 @@ func (m *MQTTInstTool) InstallTools() error {
return nil
}
-//TearDown should uninstall MQTT, but it is not required either for cloud or edge node.
-//It is defined so that MQTTInstTool implements ToolsInstaller interface
+// TearDown should uninstall MQTT, but it is not required either for cloud or edge node.
+// It is defined so that MQTTInstTool implements ToolsInstaller interface
func (m *MQTTInstTool) TearDown() error {
return nil
}
diff --git a/keadm/cmd/keadm/app/keadm.go b/keadm/cmd/keadm/app/keadm.go
index cf61b40f1..54e2d49b4 100644
--- a/keadm/cmd/keadm/app/keadm.go
+++ b/keadm/cmd/keadm/app/keadm.go
@@ -24,7 +24,7 @@ import (
"github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd"
)
-//Run executes the keadm command
+// Run executes the keadm command
func Run() error {
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
diff --git a/manifests/manifests.go b/manifests/manifests.go
index c984af956..de08cdd18 100644
--- a/manifests/manifests.go
+++ b/manifests/manifests.go
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
+
package manifests
import (
@@ -21,7 +22,6 @@ import (
"os"
)
-// FS embeds the manifests
//go:embed charts/* addons/* profiles/*
//go:embed charts/cloudcore/templates/_helpers.tpl
var FS embed.FS
diff --git a/pkg/metaserver/key.go b/pkg/metaserver/key.go
index 710752a19..e754a0b87 100644
--- a/pkg/metaserver/key.go
+++ b/pkg/metaserver/key.go
@@ -103,11 +103,17 @@ func KeyRootFunc(ctx context.Context) string {
// ParseKey parse key to group/version/resource, namespace, name
// Now key format is like below:
// 0/1 /2 /3 /4 /5
-// /core/v1/pods/{namespaces}/{name}
+//
+// /core/v1/pods/{namespaces}/{name}
+//
// 0/1 /2/3
-// /app/v1/deployments
+//
+// /app/v1/deployments
+//
// 0/1 /2 /3
-// /core/v1/endpoints
+//
+// /core/v1/endpoints
+//
// Remember that ParseKey is not responsible for verifying the validity of the content,
// for example, gvr in key /app/v1111/endpoint will be parsed as {Group:"app", Version:"v1111", Resource:"endpoint"}
func ParseKey(key string) (gvr schema.GroupVersionResource, namespace string, name string) {
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 467c69edb..39ca1b2b7 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -98,7 +98,7 @@ func ValidateNodeIP(nodeIP net.IP) error {
return fmt.Errorf("node IP: %q not found in the host's network interfaces", nodeIP.String())
}
-//Command executes command and returns output
+// Command executes command and returns output
func Command(name string, arg []string) (string, error) {
cmd := exec.Command(name, arg...)
ret, err := cmd.Output()
@@ -108,7 +108,7 @@ func Command(name string, arg []string) (string, error) {
return strings.Trim(string(ret), "\n"), nil
}
-//GetCurPath returns filepath
+// GetCurPath returns filepath
func GetCurPath() string {
file, _ := exec.LookPath(os.Args[0])
path, _ := filepath.Abs(file)
diff --git a/staging/src/github.com/kubeedge/beehive/pkg/core/model/message.go b/staging/src/github.com/kubeedge/beehive/pkg/core/model/message.go
index bdf1bec92..47404e4e3 100644
--- a/staging/src/github.com/kubeedge/beehive/pkg/core/model/message.go
+++ b/staging/src/github.com/kubeedge/beehive/pkg/core/model/message.go
@@ -210,7 +210,7 @@ func (msg *Message) BuildHeader(ID, parentID string, timestamp int64) *Message {
return msg
}
-//FillBody fills message content that you want to send
+// FillBody fills message content that you want to send
func (msg *Message) FillBody(content interface{}) *Message {
msg.Content = content
return msg
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
index 257634229..ada0f6600 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
@@ -7,7 +7,7 @@ import (
beehiveContext "github.com/kubeedge/beehive/pkg/core/context"
)
-//Constants for module name and group
+// Constants for module name and group
const (
DestinationModule = "destinationmodule"
DestinationGroup = "destinationgroup"
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
index df20d9039..806d4452e 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
@@ -7,7 +7,7 @@ import (
beehiveContext "github.com/kubeedge/beehive/pkg/core/context"
)
-//Constant for test module destination group name
+// Constant for test module destination group name
const (
DestinationGroupModule = "destinationgroupmodule"
)
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
index 768ab4823..6356b8042 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
@@ -9,7 +9,7 @@ import (
"github.com/kubeedge/beehive/pkg/core/model"
)
-//Constants for module source and group
+// Constants for module source and group
const (
SourceModule = "sourcemodule"
SourceGroup = "sourcegroup"
diff --git a/staging/src/github.com/kubeedge/viaduct/pkg/cmgr/connmgr.go b/staging/src/github.com/kubeedge/viaduct/pkg/cmgr/connmgr.go
index 28c7e71c9..e83c23d17 100644
--- a/staging/src/github.com/kubeedge/viaduct/pkg/cmgr/connmgr.go
+++ b/staging/src/github.com/kubeedge/viaduct/pkg/cmgr/connmgr.go
@@ -6,20 +6,18 @@ import (
"github.com/kubeedge/viaduct/pkg/conn"
)
-// the callback for getting connection key
+// ConnKey callback for getting connection key
type ConnKey func(connection conn.Connection) string
-// connection instances management
+// ConnectionManager instances management
type ConnectionManager struct {
connKey ConnKey
connections sync.Map
}
-// new connection manager instance
-// you the conn key like this:
-//func getConnKey(conn conn.Connection) string {
-// return conn.ConnectionState().Headers.Get("node_id")
-//}
+// NewManager instance.
+// you the conn key like this: func getConnKey(conn conn.Connection) string {
+// return conn.ConnectionState().Headers.Get("node_id")}
func NewManager(connKey ConnKey) *ConnectionManager {
keyFunc := getConnKeyDefault
if connKey != nil {
@@ -30,22 +28,22 @@ func NewManager(connKey ConnKey) *ConnectionManager {
}
}
-// get conn key default
+// getConnKeyDefault get conn key default
func getConnKeyDefault(conn conn.Connection) string {
return conn.RemoteAddr().String()
}
-// add connection into store
+// AddConnection add connection into store
func (mgr *ConnectionManager) AddConnection(conn conn.Connection) {
mgr.connections.Store(mgr.connKey(conn), conn)
}
-// delete connection from store
+// DelConnection delete connection from store
func (mgr *ConnectionManager) DelConnection(conn conn.Connection) {
mgr.connections.Delete(mgr.connKey(conn))
}
-// get connection for store
+// GetConnection get connection for store
func (mgr *ConnectionManager) GetConnection(key string) (conn.Connection, bool) {
obj, exist := mgr.connections.Load(key)
if exist {
diff --git a/tests/e2e/utils/config.go b/tests/e2e/utils/config.go
index 0ba26a532..ada13d495 100644
--- a/tests/e2e/utils/config.go
+++ b/tests/e2e/utils/config.go
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
+
package utils
import (
@@ -23,7 +24,7 @@ import (
cliflag "k8s.io/component-base/cli/flag"
)
-//config.json decode struct
+// Config decode struct
type Config struct {
AppImageURL []string `json:"image_url"`
K8SMasterForKubeEdge string `json:"k8smasterforkubeedge"`
diff --git a/tests/e2e/utils/context.go b/tests/e2e/utils/context.go
index 121becca7..c3754ef73 100644
--- a/tests/e2e/utils/context.go
+++ b/tests/e2e/utils/context.go
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
+
package utils
import (
@@ -22,19 +23,19 @@ import (
"time"
)
-//Test context struct
+// TestContext struct
type TestContext struct {
Cfg Config
}
-//NewTestContext function to build testcontext with provided config.
+// NewTestContext function to build testcontext with provided config.
func NewTestContext(cfg Config) *TestContext {
return &TestContext{
Cfg: cfg,
}
}
-//SendHTTPRequest Function to prepare the http req and send
+// SendHTTPRequest Function to prepare the http req and send
func SendHTTPRequest(method, reqAPI string) (*http.Response, error) {
var body io.Reader
var resp *http.Response
diff --git a/tests/e2e/utils/log.go b/tests/e2e/utils/log.go
index 55b4dde98..f1cffdaf0 100644
--- a/tests/e2e/utils/log.go
+++ b/tests/e2e/utils/log.go
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
+
package utils
import (
@@ -22,36 +23,36 @@ import (
"github.com/onsi/ginkgo"
)
-//Function to get time in millisec
+// nowStamp get time in millisec
func nowStamp() string {
return time.Now().Format(time.StampMilli)
}
-//functiont to log the Ginkgo framework logs
+// logf log the Ginkgo framework logs
func logf(level string, format string, args ...interface{}) {
fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
}
-//Funciton to log Filure logs
+// Fatalf log Failure logs
func Fatalf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("Fatal", msg)
ginkgo.Fail(nowStamp()+": "+msg, 1)
}
-//function for Error log
+// Errorf for Error log
func Errorf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("Error", msg)
}
-//function for log level
+// Infof for log level
func Infof(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("Info", msg)
}
-//Function to print the test case name and status of execution
+// PrintTestcaseNameandStatus print the test case name and status of execution
func PrintTestcaseNameandStatus() {
var Status string
testSpecReport := ginkgo.CurrentGinkgoTestDescription()
diff --git a/tests/e2e/utils/node.go b/tests/e2e/utils/node.go
index 27640eb24..033b356af 100644
--- a/tests/e2e/utils/node.go
+++ b/tests/e2e/utils/node.go
@@ -50,7 +50,7 @@ func getpwd() string {
return dir
}
-//DeRegisterNodeFromMaster function to deregister the node from master
+// DeRegisterNodeFromMaster function to deregister the node from master
func DeRegisterNodeFromMaster(nodehandler, nodename string) error {
resp, err := SendHTTPRequest(http.MethodDelete, nodehandler+"/"+nodename)
if err != nil {
@@ -63,7 +63,7 @@ func DeRegisterNodeFromMaster(nodehandler, nodename string) error {
return nil
}
-//GenerateNodeReqBody function to generate the node request body
+// GenerateNodeReqBody function to generate the node request body
func GenerateNodeReqBody(nodeid, nodeselector string) (map[string]interface{}, error) {
var temp map[string]interface{}
@@ -77,7 +77,7 @@ func GenerateNodeReqBody(nodeid, nodeselector string) (map[string]interface{}, e
return temp, nil
}
-//RegisterNodeToMaster function to register node to master
+// RegisterNodeToMaster function to register node to master
func RegisterNodeToMaster(UID, nodehandler, nodeselector string) error {
body, err := GenerateNodeReqBody(UID, nodeselector)
if err != nil {
@@ -117,7 +117,7 @@ func RegisterNodeToMaster(UID, nodehandler, nodeselector string) error {
return nil
}
-//CheckNodeReadyStatus function to get node status
+// CheckNodeReadyStatus function to get node status
func CheckNodeReadyStatus(nodehandler, nodename string) string {
var node v1.Node
var nodeStatus = "unknown"
@@ -142,7 +142,7 @@ func CheckNodeReadyStatus(nodehandler, nodename string) string {
return string(node.Status.Phase)
}
-//CheckNodeDeleteStatus function to check node delete status
+// CheckNodeDeleteStatus function to check node delete status
func CheckNodeDeleteStatus(nodehandler, nodename string) int {
resp, err := SendHTTPRequest(http.MethodGet, nodehandler+"/"+nodename)
if err != nil {
@@ -153,7 +153,7 @@ func CheckNodeDeleteStatus(nodehandler, nodename string) int {
return resp.StatusCode
}
-//HandleConfigmap function to create configmaps for respective edgenodes
+// HandleConfigmap function to create configmaps for respective edgenodes
func HandleConfigmap(configName chan error, operation, confighandler string, IsEdgeCore bool) {
var req *http.Request
var file string
@@ -251,7 +251,7 @@ func TaintEdgeDeployedNode(toTaint bool, taintHandler string) error {
return nil
}
-//GetNodes function to get configmaps for respective edgenodes
+// GetNodes function to get configmaps for respective edgenodes
func GetNodes(api string) v1.NodeList {
var nodes v1.NodeList
resp, err := SendHTTPRequest(http.MethodGet, api)
diff --git a/tests/e2e_edgesite/edgesite_test.go b/tests/e2e_edgesite/edgesite_test.go
index 86c5eb0a5..b5c529d68 100644
--- a/tests/e2e_edgesite/edgesite_test.go
+++ b/tests/e2e_edgesite/edgesite_test.go
@@ -35,7 +35,7 @@ import (
var DeploymentTestTimerGroup = utils.NewTestTimerGroup()
-//Run Test cases
+// Run Test cases
var _ = Describe("Application deployment test in E2E scenario using EdgeSite", func() {
var UID string
var testTimer *utils.TestTimer
diff --git a/tests/e2e_keadm/keadm_test.go b/tests/e2e_keadm/keadm_test.go
index cf57579b3..030a5ca87 100644
--- a/tests/e2e_keadm/keadm_test.go
+++ b/tests/e2e_keadm/keadm_test.go
@@ -31,7 +31,7 @@ import (
var DeploymentTestTimerGroup = utils.NewTestTimerGroup()
-//Run Test cases
+// Run Test cases
var _ = Describe("Application deployment test in keadm E2E scenario", func() {
var testTimer *utils.TestTimer
var testSpecReport GinkgoTestDescription