Skip to content

Commit

Permalink
Merge pull request #1200 from kubernetes-sigs/fix-golint2
Browse files Browse the repository at this point in the history
tes: fix golint action failure
  • Loading branch information
andyzhangx authored Mar 5, 2023
2 parents 3af023a + 38acd02 commit 95d8f00
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ jobs:
name: Go Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.19
- uses: actions/checkout@master
- name: Run linter
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.45
# https://golangci-lint.run/usage/linters/
args: -E=gofmt,deadcode,unused,varcheck,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,dupl,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s
version: v1.51
args: -E=gofmt,deadcode,unused,varcheck,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/azurefile-csi-driver

go 1.18
go 1.19

require (
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible
Expand Down
2 changes: 1 addition & 1 deletion pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
}); err != nil {
var helpLinkMsg string
if d.appendMountErrorHelpLink {
helpLinkMsg = fmt.Sprintf("\nPlease refer to http://aka.ms/filemounterror for possible causes and solutions for mount errors.")
helpLinkMsg = "\nPlease refer to http://aka.ms/filemounterror for possible causes and solutions for mount errors."
}
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %s on %s failed with %v%s", volumeID, source, cifsMountPath, err, helpLinkMsg))
}
Expand Down
13 changes: 4 additions & 9 deletions pkg/os/smb/smb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
)

func IsSmbMapped(remotePath string) (bool, error) {
cmdLine := fmt.Sprintf(`$(Get-SmbGlobalMapping -RemotePath $Env:smbremotepath -ErrorAction Stop).Status `)
cmdLine := `$(Get-SmbGlobalMapping -RemotePath $Env:smbremotepath -ErrorAction Stop).Status`
cmd := exec.Command("powershell", "/c", cmdLine)
cmd.Env = append(os.Environ(),
fmt.Sprintf("smbremotepath=%s", remotePath))
cmd.Env = append(os.Environ(), "smbremotepath="+remotePath)

out, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -47,19 +46,15 @@ func IsSmbMapped(remotePath string) (bool, error) {
// Since os.Symlink is currently being used in working code paths, no attempt is made in
// alpha to merge the paths.
func NewSmbLink(remotePath, localPath string) error {

if !strings.HasSuffix(remotePath, "\\") {
// Golang has issues resolving paths mapped to file shares if they do not end in a trailing \
// so add one if needed.
remotePath = remotePath + "\\"
}

cmdLine := fmt.Sprintf(`New-Item -ItemType SymbolicLink $Env:smblocalPath -Target $Env:smbremotepath`)
cmdLine := `New-Item -ItemType SymbolicLink $Env:smblocalPath -Target $Env:smbremotepath`
cmd := exec.Command("powershell", "/c", cmdLine)
cmd.Env = append(os.Environ(),
fmt.Sprintf("smbremotepath=%s", remotePath),
fmt.Sprintf("smblocalpath=%s", localPath),
)
cmd.Env = append(os.Environ(), "smbremotepath="+remotePath, "smblocalpath=%s"+localPath)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error linking %s to %s. output: %s, err: %v", remotePath, localPath, string(output), err)
Expand Down

0 comments on commit 95d8f00

Please # to comment.