Commit fc287626 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #45448 from zhangxiaoyu-zidif/cleancode-nfs-return-err

Automatic merge from submit-queue (batch tested with PRs 44798, 45537, 45448, 45432) nfs.go: cleancode err **What this PR does / why we need it**: The modification makes code clean, simple, and easy to inspect. **Release note**: ```release-note NONE ```
parents 93adcbd0 aec46961
......@@ -195,19 +195,15 @@ func (nfsMounter *nfsMounter) CanMount() error {
exe := exec.New()
switch runtime.GOOS {
case "linux":
_, err1 := exe.Command("/bin/ls", "/sbin/mount.nfs").CombinedOutput()
_, err2 := exe.Command("/bin/ls", "/sbin/mount.nfs4").CombinedOutput()
if err1 != nil {
if _, err := exe.Command("/bin/ls", "/sbin/mount.nfs").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs is missing")
}
if err2 != nil {
if _, err := exe.Command("/bin/ls", "/sbin/mount.nfs4").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs4 is missing")
}
return nil
case "darwin":
_, err := exe.Command("/bin/ls", "/sbin/mount_nfs").CombinedOutput()
if err != nil {
if _, err := exe.Command("/bin/ls", "/sbin/mount_nfs").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment