diff --git a/cniovs/cniovs_test.go b/cniovs/cniovs_test.go index 1970cedf..4dbaf4eb 100644 --- a/cniovs/cniovs_test.go +++ b/cniovs/cniovs_test.go @@ -657,7 +657,7 @@ func TestDelLocalDeviceVhost(t *testing.T) { // cleanup if needed defer os.RemoveAll(tc.sharedDir) defer os.RemoveAll(sharedDir) - defer func () { + defer func() { _ = unix.Unmount(sharedDir, 0) }() } else { diff --git a/cniovs/localdb.go b/cniovs/localdb.go index 9c03b8f9..c4311c47 100644 --- a/cniovs/localdb.go +++ b/cniovs/localdb.go @@ -53,7 +53,8 @@ type OvsSavedData struct { // // SaveConfig() - Some data needs to be saved for cmdDel(). -// This function squirrels the data away to be retrieved later. +// +// This function squirrels the data away to be retrieved later. func SaveConfig(conf *types.NetConf, args *skel.CmdArgs, data *OvsSavedData) error { // Current implementation is to write data to a file with the name: diff --git a/cnivpp/api/infra/infra.go b/cnivpp/api/infra/infra.go index 1525c8dc..f44b95d5 100644 --- a/cnivpp/api/infra/infra.go +++ b/cnivpp/api/infra/infra.go @@ -29,14 +29,10 @@ import ( "go.fd.io/govpp/core" ) -// // Constants -// const debugInfra = false -// // Types -// type ConnectionData struct { conn *core.Connection disconnectFlag bool diff --git a/logging/logging.go b/logging/logging.go index b8d551e2..594d4ffe 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -29,13 +29,18 @@ type Level uint32 // Common use of different level: // "panic": Code crash. // "error": Unusual event occurred (invalid input or system issue), -// so exiting code prematurely. +// +// so exiting code prematurely. +// // "warning": Unusual event occurred (invalid input or system issue), -// but continuing. +// +// but continuing. +// // "info": Basic information, indication of major code paths. // "debug": Additional information, indication of minor code branches. // "verbose": Output of larger variables in code and debug of low level -// functions. +// +// functions. const ( PanicLevel Level = iota ErrorLevel diff --git a/pkg/annotations/annotations.go b/pkg/annotations/annotations.go index d6d4089b..e2ebaa68 100644 --- a/pkg/annotations/annotations.go +++ b/pkg/annotations/annotations.go @@ -13,11 +13,11 @@ import ( "bytes" "encoding/json" "fmt" - "path/filepath" - "strings" - "os" v1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" + "os" + "path/filepath" + "strings" "github.com/go-logfmt/logfmt" diff --git a/pkg/configdata/configdata.go b/pkg/configdata/configdata.go index 6084c094..8bcaa61b 100644 --- a/pkg/configdata/configdata.go +++ b/pkg/configdata/configdata.go @@ -33,9 +33,9 @@ import ( "github.com/containernetworking/cni/pkg/skel" current "github.com/containernetworking/cni/pkg/types/100" + "github.com/intel/userspace-cni-network-plugin/logging" "github.com/intel/userspace-cni-network-plugin/pkg/annotations" "github.com/intel/userspace-cni-network-plugin/pkg/types" - "github.com/intel/userspace-cni-network-plugin/logging" ) // @@ -49,7 +49,6 @@ const DefaultVppCNIDir = "/var/run/vpp" // Types // - // // API Functions // @@ -59,15 +58,16 @@ const DefaultVppCNIDir = "/var/run/vpp" // // saveRemoteConfig() - When a config read on the host is for a Container, -// flip the location and write the data to a file. When the Container -// comes up, it will read the file via () and delete the file. This function -// writes the file. +// +// flip the location and write the data to a file. When the Container +// comes up, it will read the file via () and delete the file. This function +// writes the file. func SaveRemoteConfig(conf *types.NetConf, - args *skel.CmdArgs, - kubeClient kubernetes.Interface, - sharedDir string, - pod *v1.Pod, - ipResult *current.Result) (*v1.Pod, error) { + args *skel.CmdArgs, + kubeClient kubernetes.Interface, + sharedDir string, + pod *v1.Pod, + ipResult *current.Result) (*v1.Pod, error) { var configData types.ConfigurationData var err error @@ -168,8 +168,9 @@ func SaveRemoteConfig(conf *types.NetConf, } // CleanupRemoteConfig() - This function cleans up any remaining files -// in the passed in directory. Some of these files were used to squirrel -// data from the create so interface can be deleted properly. +// +// in the passed in directory. Some of these files were used to squirrel +// data from the create so interface can be deleted properly. // // FIXME: parameter *conf* is not used. It shall be used or removed. func CleanupRemoteConfig(conf *types.NetConf, sharedDir string) { @@ -185,10 +186,11 @@ func CleanupRemoteConfig(conf *types.NetConf, sharedDir string) { // This function deletes the input file (if provided) and the associated // directory (if provided) if the directory is empty. -// directory string - Directory file is located in, Use "" if directory -// should remain unchanged. -// filepath string - File (including directory) to be deleted. Use "" if -// only the directory should be deleted. +// +// directory string - Directory file is located in, Use "" if directory +// should remain unchanged. +// filepath string - File (including directory) to be deleted. Use "" if +// only the directory should be deleted. func FileCleanup(directory string, filepath string) (err error) { // If File is provided, delete it. @@ -214,11 +216,10 @@ func FileCleanup(directory string, filepath string) (err error) { return } - type InterfaceData struct { - Args skel.CmdArgs - NetConf types.NetConf - IPResult current.Result + Args skel.CmdArgs + NetConf types.NetConf + IPResult current.Result } func GetRemoteConfig(annotFile string) ([]*InterfaceData, string, error) { @@ -258,6 +259,5 @@ func GetRemoteConfig(annotFile string) ([]*InterfaceData, string, error) { ifaceList = append(ifaceList, &ifaceData) } - return ifaceList, mappedDir, err } diff --git a/pkg/configdata/configdata_test.go b/pkg/configdata/configdata_test.go index 059264a5..3935f22b 100644 --- a/pkg/configdata/configdata_test.go +++ b/pkg/configdata/configdata_test.go @@ -144,7 +144,7 @@ func TestSaveRemoteConfig(t *testing.T) { testType: "client_nil", brokenDir: "none", expJson: `{"containerId":"#UUID#","ifName":"#ifName#","name":"","config":{"iftype":"vhostuser","memif":{},"vhost":{"mode":"server"},"bridge":{}},"ipResult":{"dns":{}}}`, - expErr: nil, + expErr: nil, }, { name: "fail to save file to broken dir", diff --git a/usrspcni/usrspcni.go b/usrspcni/usrspcni.go index 514b317a..5978b6fd 100644 --- a/usrspcni/usrspcni.go +++ b/usrspcni/usrspcni.go @@ -24,9 +24,7 @@ import ( "github.com/intel/userspace-cni-network-plugin/pkg/types" ) -// // Exported Types -// type UsrSpCni interface { AddOnHost(conf *types.NetConf, args *skel.CmdArgs,