mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
Merge pull request #437 from rojkov/linter-checks
lint: enable exportloopref, prealloc and scopelint checks
This commit is contained in:
commit
ab1612dd7d
@ -11,6 +11,7 @@ linters:
|
||||
- deadcode
|
||||
- dogsled
|
||||
- errcheck
|
||||
- exportloopref
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocyclo
|
||||
@ -30,7 +31,9 @@ linters:
|
||||
- nakedret
|
||||
- noctx
|
||||
- nolintlint
|
||||
- prealloc
|
||||
- rowserrcheck
|
||||
- scopelint
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
@ -51,3 +54,11 @@ linters-settings:
|
||||
min-complexity: 15
|
||||
gocognit:
|
||||
min-complexity: 31
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
# Until the testing package allows pinning variables disable scopelint
|
||||
# for tests. See https://github.com/kyoh86/scopelint/issues/4.
|
||||
- scopelint
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@ -259,7 +260,7 @@ func (dp *devicePlugin) getAFU(fpath string, devName string) (*afu, error) {
|
||||
if dp.ignoreAfuIDs {
|
||||
afuID = "unused_afu_id"
|
||||
} else {
|
||||
data, err := ioutil.ReadFile(fpath)
|
||||
data, err := ioutil.ReadFile(filepath.Clean(fpath))
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
@ -278,7 +279,7 @@ func (dp *devicePlugin) getAFU(fpath string, devName string) (*afu, error) {
|
||||
}
|
||||
|
||||
func (dp *devicePlugin) getFME(interfaceIDPath string, devName string) (*region, error) {
|
||||
data, err := ioutil.ReadFile(interfaceIDPath)
|
||||
data, err := ioutil.ReadFile(filepath.Clean(interfaceIDPath))
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
@ -295,8 +296,6 @@ func (dp *devicePlugin) getFME(interfaceIDPath string, devName string) (*region,
|
||||
}
|
||||
|
||||
func (dp *devicePlugin) scanFPGAs() (dpapi.DeviceTree, error) {
|
||||
var devices []device
|
||||
|
||||
klog.V(4).Info("Start new FPGA scan")
|
||||
|
||||
fpgaFiles, err := ioutil.ReadDir(dp.sysfsDir)
|
||||
@ -305,6 +304,7 @@ func (dp *devicePlugin) scanFPGAs() (dpapi.DeviceTree, error) {
|
||||
return dp.getDevTree([]device{}), nil
|
||||
}
|
||||
|
||||
devices := make([]device, 0, len(fpgaFiles))
|
||||
for _, fpgaFile := range fpgaFiles {
|
||||
fname := fpgaFile.Name()
|
||||
|
||||
|
@ -183,8 +183,6 @@ func getRequestedResources(container corev1.Container) (map[string]int64, error)
|
||||
}
|
||||
|
||||
func (p *patcher) getPatchOps(containerIdx int, container corev1.Container) ([]string, error) {
|
||||
var ops []string
|
||||
|
||||
requestedResources, err := getRequestedResources(container)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -197,6 +195,7 @@ func (p *patcher) getPatchOps(containerIdx int, container corev1.Container) ([]s
|
||||
resources := make(map[string]int64)
|
||||
envVars := make(map[string]string)
|
||||
counter := 0
|
||||
ops := make([]string, 0, 2*len(requestedResources))
|
||||
for rname, quantity := range requestedResources {
|
||||
mode, found := p.resourceModeMap[rname]
|
||||
if !found {
|
||||
|
@ -104,7 +104,7 @@ func (pm *PatcherManager) mutate(ctx context.Context, req webhook.AdmissionReque
|
||||
Allowed: true,
|
||||
}
|
||||
|
||||
var ops []string
|
||||
ops := []string{}
|
||||
for containerIdx, container := range pod.Spec.Containers {
|
||||
patchOps, err := patcher.getPatchOps(containerIdx, container)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user