Merge pull request #765 from Zhupku/mengzezhu/upgrade-golint-version
chore: upgrade golint version
This commit is contained in:
commit
e1f2a24e82
2
.github/workflows/static.yaml
vendored
2
.github/workflows/static.yaml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
- name: Run linter
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.54
|
||||
version: v1.60
|
||||
args: -E=gofmt,unused,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,contextcheck --timeout=30m0s
|
||||
verify-helm:
|
||||
name: Verify Helm
|
||||
|
||||
@ -144,11 +144,11 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
if v != "" {
|
||||
var err error
|
||||
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s in storage class", v))
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s in storage class", v)
|
||||
}
|
||||
}
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", k))
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", k)
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,24 +168,24 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
||||
}
|
||||
// Mount nfs base share so we can create a subdirectory
|
||||
if err = cs.internalMount(ctx, nfsVol, parameters, volCap); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
|
||||
klog.Warningf("failed to unmount nfs server: %v", err.Error())
|
||||
klog.Warningf("failed to unmount nfs server: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Create subdirectory under base-dir
|
||||
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, nfsVol)
|
||||
if err = os.MkdirAll(internalVolumePath, 0777); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err)
|
||||
}
|
||||
|
||||
if mountPermissions > 0 {
|
||||
// Reset directory permissions because of umask problems
|
||||
if err = os.Chmod(internalVolumePath, os.FileMode(mountPermissions)); err != nil {
|
||||
klog.Warningf("failed to chmod subdirectory: %v", err.Error())
|
||||
klog.Warningf("failed to chmod subdirectory: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
// check whether volumeID is in the cache
|
||||
cache, err := cs.Driver.volDeletionCache.Get(volumeID, azcache.CacheReadTypeDefault)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "%v", err)
|
||||
}
|
||||
if cache != nil {
|
||||
klog.V(2).Infof("DeleteVolume: volume %s is already deleted", volumeID)
|
||||
@ -253,11 +253,11 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
}
|
||||
// mount nfs base share so we can delete the subdirectory
|
||||
if err = cs.internalMount(ctx, nfsVol, nil, volCap); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
|
||||
klog.Warningf("failed to unmount nfs server: %v", err.Error())
|
||||
klog.Warningf("failed to unmount nfs server: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -269,7 +269,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
parentDir := filepath.Dir(archivedInternalVolumePath)
|
||||
klog.V(2).Infof("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists", nfsVol.subDir, parentDir)
|
||||
if err = os.MkdirAll(parentDir, 0777); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,12 +278,12 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
if cs.Driver.removeArchivedVolumePath {
|
||||
klog.V(2).Infof("removing archived subdirectory at %v", archivedInternalVolumePath)
|
||||
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err)
|
||||
}
|
||||
klog.V(2).Infof("removed archived subdirectory at %v", archivedInternalVolumePath)
|
||||
}
|
||||
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
|
||||
}
|
||||
// make sure internalVolumePath does not exist with 1 minute timeout
|
||||
if err = waitForPathNotExistWithTimeout(internalVolumePath, time.Minute); err != nil {
|
||||
@ -294,7 +294,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
|
||||
// delete subdirectory under base-dir
|
||||
klog.V(2).Infof("removing subdirectory at %v", internalVolumePath)
|
||||
if err = os.RemoveAll(internalVolumePath); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -455,7 +455,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
|
||||
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, vol)
|
||||
klog.V(2).Infof("Removing snapshot archive at %v", internalVolumePath)
|
||||
if err = os.RemoveAll(internalVolumePath); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err)
|
||||
}
|
||||
|
||||
return &csi.DeleteSnapshotResponse{}, nil
|
||||
@ -620,7 +620,7 @@ func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfs
|
||||
case paramShare:
|
||||
baseDir = v
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in snapshot storage class", k))
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in snapshot storage class", k)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ func NewDriver(options *DriverOptions) *Driver {
|
||||
}
|
||||
|
||||
var err error
|
||||
getter := func(key string) (interface{}, error) { return nil, nil }
|
||||
getter := func(_ string) (interface{}, error) { return nil, nil }
|
||||
if n.volStatsCache, err = azcache.NewTimedCache(time.Duration(options.VolStatsCacheExpireInMinutes)*time.Minute, getter, false); err != nil {
|
||||
klog.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ func NewEmptyDriver(emptyField string) *Driver {
|
||||
}
|
||||
}
|
||||
d.volumeLocks = NewVolumeLocks()
|
||||
getter := func(key string) (interface{}, error) { return nil, nil }
|
||||
getter := func(_ string) (interface{}, error) { return nil, nil }
|
||||
d.volStatsCache, _ = azcache.NewTimedCache(time.Minute, getter, false)
|
||||
return d
|
||||
}
|
||||
@ -109,7 +109,7 @@ func TestRun(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "Successful run",
|
||||
testFunc: func(t *testing.T) {
|
||||
testFunc: func(_ *testing.T) {
|
||||
d := NewEmptyDriver("")
|
||||
d.endpoint = "tcp://127.0.0.1:0"
|
||||
d.Run(true)
|
||||
@ -117,7 +117,7 @@ func TestRun(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Successful run with node ID missing",
|
||||
testFunc: func(t *testing.T) {
|
||||
testFunc: func(_ *testing.T) {
|
||||
d := NewEmptyDriver("")
|
||||
d.endpoint = "tcp://127.0.0.1:0"
|
||||
d.nodeID = ""
|
||||
|
||||
@ -92,7 +92,7 @@ func (ns *NodeServer) NodePublishVolume(_ context.Context, req *csi.NodePublishV
|
||||
if v != "" {
|
||||
var err error
|
||||
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s", v))
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ func (ns *NodeServer) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolu
|
||||
// check if the volume stats is cached
|
||||
cache, err := ns.Driver.volStatsCache.Get(req.VolumeId, azcache.CacheReadTypeDefault)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "%v", err)
|
||||
}
|
||||
if cache != nil {
|
||||
resp := cache.(csi.NodeGetVolumeStatsResponse)
|
||||
|
||||
@ -39,7 +39,7 @@ const (
|
||||
func TestNodePublishVolume(t *testing.T) {
|
||||
ns, err := getTestNodeServer()
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatalf("%v", err.Error())
|
||||
}
|
||||
|
||||
params := map[string]string{
|
||||
@ -208,7 +208,7 @@ func TestNodePublishVolume(t *testing.T) {
|
||||
func TestNodeUnpublishVolume(t *testing.T) {
|
||||
ns, err := getTestNodeServer()
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatalf("%v", err.Error())
|
||||
}
|
||||
|
||||
errorTarget := testutil.GetWorkDirPath("error_is_likely_target", t)
|
||||
@ -276,7 +276,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
|
||||
func TestNodeGetInfo(t *testing.T) {
|
||||
ns, err := getTestNodeServer()
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatalf("%v", err.Error())
|
||||
}
|
||||
|
||||
// Test valid request
|
||||
@ -289,7 +289,7 @@ func TestNodeGetInfo(t *testing.T) {
|
||||
func TestNodeGetCapabilities(t *testing.T) {
|
||||
ns, err := getTestNodeServer()
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatalf("%v", err.Error())
|
||||
}
|
||||
|
||||
capType := &csi.NodeServiceCapability_Rpc{
|
||||
@ -358,7 +358,7 @@ func TestNodeGetVolumeStats(t *testing.T) {
|
||||
_ = makeDir(fakePath)
|
||||
ns, err := getTestNodeServer()
|
||||
if err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
t.Fatalf("%v", err.Error())
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@ -78,7 +78,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
|
||||
if proto == "unix" {
|
||||
addr = "/" + addr
|
||||
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
|
||||
klog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
|
||||
klog.Fatalf("Failed to remove %s, error: %v", addr, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
|
||||
testDriver driver.PVTestDriver
|
||||
)
|
||||
|
||||
ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) {
|
||||
ginkgo.BeforeEach(func(_ ginkgo.SpecContext) {
|
||||
checkPodsRestart := testCmd{
|
||||
command: "sh",
|
||||
args: []string{"test/utils/check_driver_pods_restart.sh"},
|
||||
|
||||
@ -26,7 +26,7 @@ import (
|
||||
func GetWorkDirPath(dir string, t *testing.T) string {
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get working directory: %s", err)
|
||||
t.Fatalf("failed to get working directory: %v", err)
|
||||
}
|
||||
return fmt.Sprintf("%s%c%s", path, os.PathSeparator, dir)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user