mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	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 ```
This commit is contained in:
		@@ -195,19 +195,15 @@ func (nfsMounter *nfsMounter) CanMount() error {
 | 
				
			|||||||
	exe := exec.New()
 | 
						exe := exec.New()
 | 
				
			||||||
	switch runtime.GOOS {
 | 
						switch runtime.GOOS {
 | 
				
			||||||
	case "linux":
 | 
						case "linux":
 | 
				
			||||||
		_, err1 := exe.Command("/bin/ls", "/sbin/mount.nfs").CombinedOutput()
 | 
							if _, err := exe.Command("/bin/ls", "/sbin/mount.nfs").CombinedOutput(); err != nil {
 | 
				
			||||||
		_, err2 := exe.Command("/bin/ls", "/sbin/mount.nfs4").CombinedOutput()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if err1 != nil {
 | 
					 | 
				
			||||||
			return fmt.Errorf("Required binary /sbin/mount.nfs is missing")
 | 
								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 fmt.Errorf("Required binary /sbin/mount.nfs4 is missing")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	case "darwin":
 | 
						case "darwin":
 | 
				
			||||||
		_, err := exe.Command("/bin/ls", "/sbin/mount_nfs").CombinedOutput()
 | 
							if _, err := exe.Command("/bin/ls", "/sbin/mount_nfs").CombinedOutput(); err != nil {
 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
 | 
								return fmt.Errorf("Required binary /sbin/mount_nfs is missing")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user