Skip to content

Commit

Permalink
Merge pull request #988 from mmorel-35/linter-gocritic
Browse files Browse the repository at this point in the history
enable gocritic linter
  • Loading branch information
squeed authored Oct 18, 2023
2 parents 2cfe797 + 4683716 commit 82b44c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ linters:
- errorlint
- gci
- ginkgolinter
- gocritic
- gofumpt
- govet
- ineffassign
Expand Down
7 changes: 4 additions & 3 deletions libcni/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ func ConfListFromBytes(bytes []byte) (*NetworkConfigList, error) {
if !ok {
return nil, fmt.Errorf("error parsing configuration list: invalid disableCheck type %T", rawDisableCheck)
}
if strings.ToLower(disableCheckStr) == "false" {
switch {
case strings.ToLower(disableCheckStr) == "false":
disableCheck = false
} else if strings.ToLower(disableCheckStr) == "true" {
case strings.ToLower(disableCheckStr) == "true":
disableCheck = true
} else {
default:
return nil, fmt.Errorf("error parsing configuration list: invalid disableCheck value %q", disableCheckStr)
}
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/invoke/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ func fixupResultVersion(netconf, result []byte) (string, []byte, error) {
// "encoding/json"
// "path"
// "strings"
//)
// )
//
//type fakeExec struct {
// type fakeExec struct {
// version.PluginDecoder
//}
// }
//
//func (f *fakeExec) ExecPlugin(pluginPath string, stdinData []byte, environ []string) ([]byte, error) {
// func (f *fakeExec) ExecPlugin(pluginPath string, stdinData []byte, environ []string) ([]byte, error) {
// net := &types.NetConf{}
// err := json.Unmarshal(stdinData, net)
// if err != nil {
Expand All @@ -109,14 +109,14 @@ func fixupResultVersion(netconf, result []byte) (string, []byte, error) {
// }
// }
// return []byte("{\"CNIVersion\":\"0.4.0\"}"), nil
//}
// }
//
//func (f *fakeExec) FindInPath(plugin string, paths []string) (string, error) {
// func (f *fakeExec) FindInPath(plugin string, paths []string) (string, error) {
// if len(paths) > 0 {
// return path.Join(paths[0], plugin), nil
// }
// return "", fmt.Errorf("failed to find plugin %s in paths %v", plugin, paths)
//}
// }

func ExecPluginWithResult(ctx context.Context, pluginPath string, netconf []byte, args CNIArgs, exec Exec) (types.Result, error) {
if exec == nil {
Expand Down
8 changes: 4 additions & 4 deletions plugins/test/noop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ func debugBehavior(args *skel.CmdArgs, command string) error {
return err
}
}

if debug.ReportError != "" {
switch {
case debug.ReportError != "":
return errors.New(debug.ReportError)
} else if debug.ReportResult == "PASSTHROUGH" || debug.ReportResult == "INJECT-DNS" {
case debug.ReportResult == "PASSTHROUGH" || debug.ReportResult == "INJECT-DNS":
prevResult := netConf.PrevResult
if debug.ReportResult == "INJECT-DNS" {
newResult, err := current.NewResultFromResult(netConf.PrevResult)
Expand All @@ -161,7 +161,7 @@ func debugBehavior(args *skel.CmdArgs, command string) error {
if err != nil {
return err
}
} else if debug.ReportResult != "" {
case debug.ReportResult != "":
_, err = os.Stdout.WriteString(debug.ReportResult)
if err != nil {
return err
Expand Down

0 comments on commit 82b44c5

Please sign in to comment.