Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: ^1.16
go-version: ^1.25
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: ^1.16
go-version: ^1.25
id: go

- name: Check out code into the Go module directory
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: ^1.19
go-version: ^1.25
- uses: actions/checkout@master
- name: Run linter
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.64
args: -E=gofmt,unused,ineffassign,revive,misspell,copyloopvar,asciicheck,bodyclose,contextcheck,dogsled,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s
version: v2.4.0
args: --timeout=30m0s
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: 1.24.6
go-version: 1.25
id: go

- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: ^1.16
go-version: ^1.25
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: ^1.16
go-version: ^1.25
id: go
- name: Checkout code
uses: actions/checkout@v5
Expand Down
52 changes: 40 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
linters-settings:
depguard:
rules:
main:
files:
- $all
- "!$test"
allow:
- $gostd
- k8s.io
- sigs.k8s.io
- github.com
version: "2"

linters:
settings:
depguard:
rules:
main:
files:
- $all
- '!$test'
allow:
- $gostd
- k8s.io
- sigs.k8s.io
- github.com
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
- test/utils/azure/azure_helpers.go
- vendor$
formatters:
enable:
- gofmt
- goimports
- gofumpt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- vendor$
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kubernetes-csi/csi-driver-smb

go 1.24
go 1.25

godebug winsymlink=0

Expand Down
2 changes: 1 addition & 1 deletion pkg/csi-common/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewCSIDriver(name string, v string, nodeID string) *CSIDriver {
// TODO version format and validation
if len(v) == 0 {
klog.Errorf("Version argument missing, now skip it")
//return nil
// return nil
}

driver := CSIDriver{
Expand Down
7 changes: 1 addition & 6 deletions pkg/csi-common/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ const (
fakeNodeID = "fakeNodeID"
)

var (
vendorVersion = "0.3.0"
)
var vendorVersion = "0.3.0"

func NewFakeDriver() *CSIDriver {

driver := NewCSIDriver(fakeDriverName, vendorVersion, fakeNodeID)

return driver
Expand Down Expand Up @@ -102,7 +99,6 @@ func TestNewCSIDriver(t *testing.T) {
}

func TestGetVolumeCapabilityAccessModes(t *testing.T) {

d := NewFakeDriver()

// Test no volume access modes.
Expand Down Expand Up @@ -159,7 +155,6 @@ func TestValidateControllerServiceRequest(t *testing.T) {
// Test controller service clone volumes is supported
err = d.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CLONE_VOLUME)
assert.NoError(t, err)

}

func TestValidateNodeServiceRequest(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/csi-common/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (s *nonBlockingGRPCServer) ForceStop() {
}

func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, testMode bool) {

proto, addr, err := ParseEndpoint(endpoint)
if err != nil {
klog.Fatal(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/csi-common/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestServe(_ *testing.T) {
s := nonBlockingGRPCServer{}
s.server = grpc.NewServer()
s.wg = sync.WaitGroup{}
//need to add one here as the actual also requires one.
// need to add one here as the actual also requires one.
s.wg.Add(1)
s.serve("tcp://127.0.0.1:0", nil, nil, nil, true)
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/csi-common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ limitations under the License.
package csicommon

import (
"context"
"fmt"
"strings"

"context"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
"google.golang.org/grpc"
Expand All @@ -35,7 +34,7 @@ func ParseEndpoint(ep string) (string, string, error) {
return s[0], s[1], nil
}
}
return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
}

func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {
Expand Down
10 changes: 5 additions & 5 deletions pkg/csi-common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

func TestParseEndpoint(t *testing.T) {
//Valid unix domain socket endpoint
// Valid unix domain socket endpoint
sockType, addr, err := ParseEndpoint("unix://fake.sock")
assert.NoError(t, err)
assert.Equal(t, sockType, "unix")
Expand All @@ -41,25 +41,25 @@ func TestParseEndpoint(t *testing.T) {
assert.Equal(t, sockType, "unix")
assert.Equal(t, addr, "/fakedir/fakedir/fake.sock")

//Valid unix domain socket with uppercase
// Valid unix domain socket with uppercase
sockType, addr, err = ParseEndpoint("UNIX://fake.sock")
assert.NoError(t, err)
assert.Equal(t, sockType, "UNIX")
assert.Equal(t, addr, "fake.sock")

//Valid TCP endpoint with ip
// Valid TCP endpoint with ip
sockType, addr, err = ParseEndpoint("tcp://127.0.0.1:80")
assert.NoError(t, err)
assert.Equal(t, sockType, "tcp")
assert.Equal(t, addr, "127.0.0.1:80")

//Valid TCP endpoint with uppercase
// Valid TCP endpoint with uppercase
sockType, addr, err = ParseEndpoint("TCP://127.0.0.1:80")
assert.NoError(t, err)
assert.Equal(t, sockType, "TCP")
assert.Equal(t, addr, "127.0.0.1:80")

//Valid TCP endpoint with hostname
// Valid TCP endpoint with hostname
sockType, addr, err = ParseEndpoint("tcp://fakehost:80")
assert.NoError(t, err)
assert.Equal(t, sockType, "tcp")
Expand Down
6 changes: 4 additions & 2 deletions pkg/mounter/refcounter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import (
"sync"
)

var basePath = "c:\\csi\\smbmounts"
var mutexes sync.Map
var (
basePath = "c:\\csi\\smbmounts"
mutexes sync.Map
)

func lock(key string) func() {
value, _ := mutexes.LoadOrStore(key, &sync.Mutex{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/mounter/safe_mounter_host_process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (mounter *winMounter) IsLikelyNotMountPoint(path string) (bool, error) {
// Currently the make dir is only used from the staging code path, hence we call it
// with Plugin context..
func (mounter *winMounter) MakeDir(path string) error {
return os.MkdirAll(normalizeWindowsPath(path), 0755)
return os.MkdirAll(normalizeWindowsPath(path), 0o755)
}

// ExistsPath - Checks if a path exists. Unlike util ExistsPath, this call does not perform follow link.
Expand Down
6 changes: 4 additions & 2 deletions pkg/os/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (
"k8s.io/klog/v2"
)

var invalidPathCharsRegexWindows = regexp.MustCompile(`["/\:\?\*|]`)
var absPathRegexWindows = regexp.MustCompile(`^[a-zA-Z]:\\`)
var (
invalidPathCharsRegexWindows = regexp.MustCompile(`["/\:\?\*|]`)
absPathRegexWindows = regexp.MustCompile(`^[a-zA-Z]:\\`)
)

func containsInvalidCharactersWindows(path string) bool {
if isAbsWindows(path) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
// Create subdirectory under base-dir
// TODO: revisit permissions
internalVolumePath := getInternalVolumePath(d.workingMountDir, smbVol)
if err = os.MkdirAll(internalVolumePath, 0777); err != nil {
if err = os.MkdirAll(internalVolumePath, 0o777); err != nil {
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err)
}

Expand Down Expand Up @@ -215,7 +215,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
if strings.Contains(smbVol.subDir, "/") {
parentDir := filepath.Dir(archivedInternalVolumePath)
klog.V(2).Infof("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists", smbVol.subDir, parentDir)
if err = os.MkdirAll(parentDir, 0777); err != nil {
if err = os.MkdirAll(parentDir, 0o777); err != nil {
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err)
}
}
Expand All @@ -235,7 +235,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
} else {
if _, err := os.Lstat(internalVolumePath); err == nil {
if err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
return os.Chmod(path, 0777)
return os.Chmod(path, 0o777)
}); err2 != nil {
klog.Errorf("failed to chmod subdirectory: %v", err2)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/smb/fake_mounter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ func TestIsLikelyNotMountPoint(t *testing.T) {
file: "./error_is_likely_target",
expectedErr: fmt.Errorf("fake IsLikelyNotMountPoint: fake error"),
},
{desc: "[Success] Successful run",
{
desc: "[Success] Successful run",
file: targetTest,
expectedErr: nil,
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/smb/identityserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package smb

import (
"context"
"reflect"
"testing"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"reflect"
"testing"
)

func TestGetPluginInfo(t *testing.T) {
Expand Down
Loading
Loading