Skip to content

Commit 3169f6b

Browse files
committed
additional cleanup of code
1 parent bd14f62 commit 3169f6b

10 files changed

Lines changed: 27 additions & 24 deletions

File tree

.golangci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ linters:
2222
# unused detects unused variables, constants, functions, etc.
2323
- unused
2424
# gosec is a security checker
25-
# - gosec
25+
#- gosec
2626
# revive is a more opinionated, customizable alternative to golint
2727
- whitespace
2828
# misspell checks for misspelled words
@@ -32,11 +32,10 @@ linters:
3232
# bidichk checks for bidirectional Unicode characters
3333
- bidichk
3434
# gocritic checks for code quality issues
35-
# - gocritic
35+
- gocritic
3636
# govet checks for suspicious constructs and potential bugs
3737
- govet
38-
# modernize checks for modern Go language features
39-
# - modernize
38+
4039

4140
disable:
4241
- errcheck

ReleaseNotes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ This release introduces potentially **BREAKING CHANGES** If you are converting f
6868
- Enabled **Container Image Signing** using `cosign` (Keyless signing).
6969
- Added **SBOM** (Software Bill of Materials) generation for all release artifacts.
7070
- **Build Hygiene**: Removed mutating hooks (e.g., `go mod tidy`) from the release pipeline to ensure immutable builds.
71+
72+
# v1.5.1
73+
- Made change to how we handle nfsClientAccess lists. Previously we would set up a static entry as part of the client-config.yaml file. We are now settings this as a part of the storageclass definition. This allows for better control over the nfsClientAccess list and allows for the use of CIDR notation and wildcard notation.
74+
- **NOTE:** This is a "breaking change". You will need to update your storageclass definition file to include the nfsClientAccess list, if you need this feature. If you do not include the nfsClientAccess list, the default value is "node" which reverts to the upstream behavior of only allowing the node to access the share.
75+
- Need to look at snapshot functionality it may need to be fixed to support this as well.

pkg/driver/multipath.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func lsblk(devicePaths []string, strict bool) ([]Device, error) {
194194
if parent.Children == nil {
195195
parent.Children = []Device{}
196196
}
197+
//nolint:gocritic // intentional branch from base slice
197198
parent.Children = append(devicesMap[pkName].Children, *device)
198199
}
199200

pkg/driver/nodeserver.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ func (t *tools) getExistedVolumeMountPath(targetIqn string, mappingIndex int) st
9191
func getVolumeMountPath(iscsiDevPaths []string) string {
9292
var path string
9393

94-
if len(iscsiDevPaths) > 1 { // check multipath exist
94+
switch len(iscsiDevPaths) {
95+
case 0:
96+
return ""
97+
case 1:
98+
path = iscsiDevPaths[0]
99+
default: // len > 1, check multipath exist
95100
devices, err := lsblk(iscsiDevPaths, true)
96101
if err != nil {
97102
log.Errorf("Failed to lsblk for iscsi devices: %v", err)
@@ -104,10 +109,6 @@ func getVolumeMountPath(iscsiDevPaths []string) string {
104109
return ""
105110
}
106111
path = filepath.Join("/dev/mapper", multipathDevice.Name)
107-
} else if len(iscsiDevPaths) == 1 {
108-
path = iscsiDevPaths[0]
109-
} else {
110-
return ""
111112
}
112113

113114
if err := waitForDevicePathToExist(path); err != nil {
@@ -328,10 +329,6 @@ func (ns *nodeServer) setNFSVolumePrivilege(sourcePath string, hostnames []strin
328329
return fmt.Errorf("failed to get DSM[%s]", dsmIp)
329330
}
330331

331-
//priv := webapi.SharePrivilege{
332-
// ShareName: shareName,
333-
//}
334-
335332
// load existing privileges
336333
priv, err := dsm.ShareNfsPrivilegeLoad(shareName)
337334
if err != nil {

pkg/dsm/service/dsm.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,12 @@ func (service *DsmService) CreateVolume(spec *models.CreateK8sVolumeSpec) (*mode
598598

599599
var k8sVolume *models.K8sVolumeRespSpec
600600
var err error
601-
if spec.Protocol == utils.ProtocolIscsi {
601+
switch spec.Protocol {
602+
case utils.ProtocolIscsi:
602603
k8sVolume, err = service.createVolumeByDsm(dsm, spec)
603-
} else if spec.Protocol == utils.ProtocolSmb {
604+
case utils.ProtocolSmb:
604605
k8sVolume, err = service.createSMBorNFSVolumeByDsm(dsm, spec)
605-
} else if spec.Protocol == utils.ProtocolNfs {
606+
case utils.ProtocolNfs:
606607
if !isNfsVersionSupport(dsm, spec.NfsVersion) {
607608
continue
608609
}

pkg/dsm/webapi/dsmwebapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (dsm *DSM) Login() error {
185185

186186
resp, err := dsm.sendRequestWithoutConnectionCheck("", &LoginResp{}, params, "webapi/auth.cgi")
187187
if err != nil {
188-
r, _ := regexp.Compile("passwd=.*&")
188+
r := regexp.MustCompile("passwd=.*&")
189189
temp := r.ReplaceAllString(err.Error(), "")
190190

191191
return fmt.Errorf("%s", temp)

pkg/utils/error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (BadParametersError) Error() string {
3535
return "Invalid input value"
3636
}
3737

38-
// ISCSI errors
38+
// ISCSI errors.
3939
func (NoSuchLunError) Error() string {
4040
return "No such LUN"
4141
}
@@ -64,7 +64,7 @@ func (e IscsiDefaultError) Error() string {
6464
return fmt.Sprintf("ISCSI API error. Error code: %d", e.ErrCode)
6565
}
6666

67-
// Share errors
67+
// Share errors.
6868
func (NoSuchShareError) Error() string {
6969
return "No such share"
7070
}

pkg/utils/hostexec/hostexec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"k8s.io/utils/exec"
1212
)
1313

14-
// defaultSearchPath for running commands without absolute paths
14+
// defaultSearchPath for running commands without absolute paths.
1515
var defaultSearchPath = []string{
1616
"/usr/local/sbin",
1717
"/usr/local/bin",
@@ -34,7 +34,7 @@ type hostexec struct {
3434
chrootDir string
3535
}
3636

37-
// New creates an instance of hostexec to execute commands in the given environment
37+
// New creates an instance of hostexec to execute commands in the given environment.
3838
func New(cmdMap map[string]string, chrootDir string) (Executor, error) {
3939
// If chroot directory is defined, check that directory exists or return an error
4040
if chrootDir != "" {

pkg/utils/hostexec/hostexec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func TestHostexec_wrap(t *testing.T) {
304304
}
305305
}
306306

307-
// dummyCmd statisfies the interface for exec.Cmd for testing purposes
307+
// dummyCmd statisfies the interface for exec.Cmd for testing purposes.
308308
type dummyCmd struct{}
309309

310310
func (dummyCmd) Run() error { return nil }
@@ -321,7 +321,7 @@ func (dummyCmd) Start() error { return nil }
321321
func (dummyCmd) Wait() error { return nil }
322322
func (dummyCmd) Stop() {}
323323

324-
// dummyInterface satisfies the interface for exec.Interface for testing purposes
324+
// dummyInterface satisfies the interface for exec.Interface for testing purposes.
325325
type dummyInterface struct {
326326
commandFunc func(string, ...string) exec.Cmd
327327
commandContextFunc func(context.Context, string, ...string) exec.Cmd

pkg/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func BytesToMB(size int64) int64 {
4343
return size / UnitMB
4444
}
4545

46-
// Ceiling
46+
// Ceiling.
4747
func BytesToMBCeil(size int64) int64 {
4848
return (size + UnitMB - 1) / UnitMB
4949
}

0 commit comments

Comments
 (0)