Fix linter warning message (#1057)

This commit is contained in:
Tomofumi Hayashi
2023-04-07 00:20:04 +09:00
committed by GitHub
parent 1add898a3c
commit 5bce250398
9 changed files with 16 additions and 30 deletions

View File

@@ -47,12 +47,12 @@ type fakeResourceServer struct {
server *grpc.Server
}
//TODO: This is stub code for test, but we may need to change for the testing we use this API in the future...
func (m *fakeResourceServer) GetAllocatableResources(ctx context.Context, req *podresourcesapi.AllocatableResourcesRequest) (*podresourcesapi.AllocatableResourcesResponse, error) {
// TODO: This is stub code for test, but we may need to change for the testing we use this API in the future...
func (m *fakeResourceServer) GetAllocatableResources(_ context.Context, _ *podresourcesapi.AllocatableResourcesRequest) (*podresourcesapi.AllocatableResourcesResponse, error) {
return &podresourcesapi.AllocatableResourcesResponse{}, nil
}
func (m *fakeResourceServer) List(ctx context.Context, req *podresourcesapi.ListPodResourcesRequest) (*podresourcesapi.ListPodResourcesResponse, error) {
func (m *fakeResourceServer) List(_ context.Context, _ *podresourcesapi.ListPodResourcesRequest) (*podresourcesapi.ListPodResourcesResponse, error) {
podName := "pod-name"
podNamespace := "pod-namespace"
containerName := "container-name"

View File

@@ -107,7 +107,7 @@ func getIfname(delegate *types.DelegateNetConf, argif string, idx int) string {
return fmt.Sprintf("net%d", idx)
}
func getDelegateDeviceInfo(delegate *types.DelegateNetConf, runtimeConf *libcni.RuntimeConf) (*nettypes.DeviceInfo, error) {
func getDelegateDeviceInfo(_ *types.DelegateNetConf, runtimeConf *libcni.RuntimeConf) (*nettypes.DeviceInfo, error) {
// If the DPDeviceInfoFile was created, it was copied to the CNIDeviceInfoFile.
// If the DPDeviceInfoFile was not created, CNI might have created it. So
// either way, load CNIDeviceInfoFile.

View File

@@ -146,7 +146,7 @@ func ParseEnvironment(environ []string) map[string]string {
return m
}
func (f *fakeExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData []byte, environ []string) ([]byte, error) {
func (f *fakeExec) ExecPlugin(_ context.Context, pluginPath string, stdinData []byte, environ []string) ([]byte, error) {
envMap := ParseEnvironment(environ)
cmd := envMap["CNI_COMMAND"]
var index int

View File

@@ -92,7 +92,7 @@ func SetDefaultGW(netnsPath string, ifName string, gateways []net.IP) error {
}
// DeleteDefaultGWCache updates libcni cache to remove default gateway routes in result
func DeleteDefaultGWCache(cacheDir string, rt *libcni.RuntimeConf, netName string, ifName string, ipv4, ipv6 bool) error {
func DeleteDefaultGWCache(cacheDir string, rt *libcni.RuntimeConf, netName string, _ string, ipv4, ipv6 bool) error {
cacheFile := filepath.Join(cacheDir, "results", fmt.Sprintf("%s-%s-%s", netName, rt.ContainerID, rt.IfName))
cache, err := os.ReadFile(cacheFile)
@@ -264,7 +264,7 @@ func deleteDefaultGWResult020(result map[string]interface{}, ipv4, ipv6 bool) (m
}
// AddDefaultGWCache updates libcni cache to add default gateway result
func AddDefaultGWCache(cacheDir string, rt *libcni.RuntimeConf, netName string, ifName string, gw []net.IP) error {
func AddDefaultGWCache(cacheDir string, rt *libcni.RuntimeConf, netName string, _ string, gw []net.IP) error {
cacheFile := filepath.Join(cacheDir, "results", fmt.Sprintf("%s-%s-%s", netName, rt.ContainerID, rt.IfName))
cache, err := os.ReadFile(cacheFile)

View File

@@ -89,6 +89,7 @@ func NewMultusConfig(pluginName string, cniVersion string, configurationOptions
return multusConfig, err
}
// ParseMultusConfig parses multus config from configPath and create MultusConf.
func ParseMultusConfig(configPath string) (*MultusConf, error) {
config, err := os.ReadFile(configPath)
if err != nil {

View File

@@ -499,7 +499,7 @@ func cmdDelegateAdd(cmdArgs *skel.CmdArgs, k8sArgs *types.K8sArgs, exec invoke.E
return serializeResult(result)
}
func cmdDelegateCheck(cmdArgs *skel.CmdArgs, k8sArgs *types.K8sArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo, multusConfig *types.NetConf) error {
func cmdDelegateCheck(cmdArgs *skel.CmdArgs, k8sArgs *types.K8sArgs, exec invoke.Exec, _ *k8s.ClientInfo, multusConfig *types.NetConf) error {
delegateCNIConf := &types.DelegateNetConf{}
if err := json.Unmarshal(cmdArgs.StdinData, delegateCNIConf); err != nil {
return err

View File

@@ -46,17 +46,17 @@ const suiteName = "Thick CNI architecture"
type fakeExec struct{}
// ExecPlugin executes the plugin
func (fe *fakeExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData []byte, environ []string) ([]byte, error) {
func (fe *fakeExec) ExecPlugin(_ context.Context, _ string, _ []byte, _ []string) ([]byte, error) {
return []byte("{}"), nil
}
// FindInPath finds in path
func (fe *fakeExec) FindInPath(plugin string, paths []string) (string, error) {
func (fe *fakeExec) FindInPath(_ string, _ []string) (string, error) {
return "", nil
}
// Decode decodes
func (fe *fakeExec) Decode(jsonBytes []byte) (version.PluginInfo, error) {
func (fe *fakeExec) Decode(_ []byte) (version.PluginInfo, error) {
return nil, nil
}
@@ -221,10 +221,7 @@ func prepareCNIEnv(netnsPath string, namespaceName string, podName string, podUI
if err := os.Setenv("CNI_NETNS", netnsPath); err != nil {
return err
}
if err := os.Setenv("CNI_ARGS", cniArgs); err != nil {
return err
}
return nil
return os.Setenv("CNI_ARGS", cniArgs)
}
func teardownCNIEnv() error {
@@ -237,10 +234,7 @@ func teardownCNIEnv() error {
if err := os.Unsetenv("CNI_NETNS"); err != nil {
return err
}
if err := os.Unsetenv("CNI_ARGS"); err != nil {
return err
}
return nil
return os.Unsetenv("CNI_ARGS")
}
func createFakePod(k8sClient *k8s.ClientInfo, podName string) error {

View File

@@ -22,7 +22,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/k8sclient"
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/types"
)
// Metrics represents server's metrics.
@@ -40,13 +39,3 @@ type Server struct {
serverConfig []byte
metrics *Metrics
}
// ShimNetConf for the shim cni config file written in json
type ShimNetConf struct {
types.NetConf
MultusSocketDir string `json:"socketDir"`
LogFile string `json:"logFile,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
LogToStderr bool `json:"logToStderr,omitempty"`
}

View File

@@ -420,8 +420,10 @@ func LoadNetConf(bytes []byte) (*NetConf, error) {
const (
// const block for multus-daemon configs
// DefaultMultusDaemonConfigFile is the Default path of the config file
DefaultMultusDaemonConfigFile = "/etc/cni/net.d/multus.d/daemon-config.json"
// DefaultMultusRunDir specifies default RunDir for multus
DefaultMultusRunDir = "/run/multus/"
)