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
6 changes: 3 additions & 3 deletions .github/workflows/trivy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v6
with:
go-version: 1.24.9
go-version: 1.25
id: go

- name: Checkout code
uses: actions/checkout@v6

- name: Build an image from Dockerfile
run: |
export PUBLISH=true
export REGISTRY=test
export IMAGE_VERSION=latest
export DOCKER_CLI_EXPERIMENTAL=enabled
make container

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
env:
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@v6
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$
12 changes: 6 additions & 6 deletions 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.0
go 1.25

godebug winsymlink=0

Expand All @@ -21,12 +21,12 @@ require (
go.uber.org/goleak v1.3.0
golang.org/x/net v0.47.0
google.golang.org/grpc v1.65.0
k8s.io/api v0.31.12
k8s.io/apimachinery v0.31.12
k8s.io/client-go v0.31.12
k8s.io/component-base v0.31.12
k8s.io/api v0.31.14
k8s.io/apimachinery v0.31.14
k8s.io/client-go v0.31.14
k8s.io/component-base v0.31.14
k8s.io/klog/v2 v2.130.1
k8s.io/kubernetes v1.31.12
k8s.io/kubernetes v1.31.14
k8s.io/mount-utils v0.32.0
k8s.io/pod-security-admission v0.31.12
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -417,20 +417,20 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.31.12 h1:yysm83xHIoKAwfm2w0dT6Yz7vfWzl841AEMI7Y8wDa8=
k8s.io/api v0.31.12/go.mod h1:f/srhhI7aDs9K4s0W1GX4/zb+cIf5uWrBjGyoO/XgJc=
k8s.io/api v0.31.14 h1:xYn/S/WFJsksI7dk/5uBRd3Umm/D8W5g7sRnd4csotA=
k8s.io/api v0.31.14/go.mod h1:K8fvRey4z73RAuxBZCma7WtY8WFvkViYhfFLCMT4xgA=
k8s.io/apiextensions-apiserver v0.31.12 h1:d32I3VReAly5Qoc9ZXhO4/iObYmm7Jk6VvAeRAbg/MA=
k8s.io/apiextensions-apiserver v0.31.12/go.mod h1:KcBI/Z/WQmbffBwfqQmqHhALhvun5JNJJh8Y29CJwUo=
k8s.io/apimachinery v0.31.12 h1:y34W8rNKc+jDxUvEXarjahqM6vOV5iqgZPuRqRuyEh8=
k8s.io/apimachinery v0.31.12/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
k8s.io/apimachinery v0.31.14 h1:/eMIwjv+GFm6A/sSGlB1NupBU6wTDPhEWsju0Fj69kY=
k8s.io/apimachinery v0.31.14/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
k8s.io/apiserver v0.31.12 h1:W5hKS78HC/llxTLBICR/xXScPkc5sPkDA66pyAin+mQ=
k8s.io/apiserver v0.31.12/go.mod h1:f0EWMQvAmOfNBrYYVesqnQFrfMyDYlxVUOLm/RNDbP8=
k8s.io/client-go v0.31.12 h1:JJhouOoU1bKdPWplkZ2CpYA74+lxj3Zsn15aoGLX6Hk=
k8s.io/client-go v0.31.12/go.mod h1:kjQ5WSec9ShP3T1auTDFW4bTqgmJdBuZPsjq5FqeuYE=
k8s.io/client-go v0.31.14 h1:d4/G0xfksNIbMWH7ghjzOwC5bTAwQ20gABTjZw7fLlQ=
k8s.io/client-go v0.31.14/go.mod h1:0uRpRB7r5QwtsbxEngZPkbcIVoNdAQAPIcopgiXjhQc=
k8s.io/cloud-provider v0.31.12 h1:la9A7dGy0VpcnI5nNZ7/RhU4/0ZoAVx6QM6T+Lze96s=
k8s.io/cloud-provider v0.31.12/go.mod h1:VKHFFjRqXQNryOxbW+xE/0tL8qm8ejxaQ0t3TRA2AMc=
k8s.io/component-base v0.31.12 h1:Z7SYHg782bY1NLGezTJYRZGPeywWVtFpE35iOEam//4=
k8s.io/component-base v0.31.12/go.mod h1:r6wrhZ7BrjAUhGZttUT6MNJdn0McPWF5RPz/xcQY3xI=
k8s.io/component-base v0.31.14 h1:VNjBuEMmvlwL4twRlMmlaVmsodIRaNivXcZoAx1/x7Q=
k8s.io/component-base v0.31.14/go.mod h1:9ogYcJBUdB4VQ/OMgInYVRScC9bguXxSEEZPsInY+uM=
k8s.io/component-helpers v0.31.12 h1:Mb9/Ijz0euQQ2v2IEgtKkvWBbDeMTq2fqHs1OoXPxGM=
k8s.io/component-helpers v0.31.12/go.mod h1:62Zm0UNTFymcAUItaHCL+g9Qbco1WcSuiUvVSKEQtvk=
k8s.io/controller-manager v0.31.12 h1:wrRs4CWP2ZtL5JnyW9QaTgD9DB1YQI7Sr68ifKF9n+M=
Expand All @@ -447,8 +447,8 @@ k8s.io/kubectl v0.31.12 h1:+f0KlQcVYX/7J7ii0AGRwCZYVx55u4dOj3Irrh17Daw=
k8s.io/kubectl v0.31.12/go.mod h1:BbqRvKt1mdJLdk+0Qovx38/d2MCLwTA31I8IN+Fql1s=
k8s.io/kubelet v0.31.12 h1:iSaYgKgLig52YOqsu+3wIXq/p++sawwQM59D7t0gIgQ=
k8s.io/kubelet v0.31.12/go.mod h1:lOqTjK7k1wmGMPanLMykpEYYyfjNgCu9EDG6kYqu2Jc=
k8s.io/kubernetes v1.31.12 h1:dPgK1slI7p/D3I2J1NA6UfBeMMHcjB91rHdXMpx8fkU=
k8s.io/kubernetes v1.31.12/go.mod h1:9xmT2buyTYj8TRKwRae7FcuY8k5+xlxv7VivvO0KKfs=
k8s.io/kubernetes v1.31.14 h1:UtjLfqvXLuSVDdJ4+NpQCIfFkKkLnAAVmxAEMsnkhjk=
k8s.io/kubernetes v1.31.14/go.mod h1:9xmT2buyTYj8TRKwRae7FcuY8k5+xlxv7VivvO0KKfs=
k8s.io/mount-utils v0.32.0 h1:KOQAhPzJICATXnc6XCkWoexKbkOexRnMCUW8APFfwg4=
k8s.io/mount-utils v0.32.0/go.mod h1:Kun5c2svjAPx0nnvJKYQWhfeNW+O0EpzHgRhDcYoSY0=
k8s.io/pod-security-admission v0.31.12 h1:lL+0Mn2MqTdFqgRPo0u+nO9/GhaBB/MrOxJLILw3oO4=
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