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
```
pull/6/head
Kubernetes Submit Queue 2017-05-09 08:29:37 -07:00 committed by GitHub
commit fc28762671
1 changed files with 3 additions and 7 deletions

View File

@ -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")
}
}