Merge pull request #76944 from SataQiu/fix-golint-volume-20190423

Fix golint failures of pkg/volume/nfs
This commit is contained in:
Kubernetes Prow Robot 2019-04-30 17:31:12 -07:00 committed by GitHub
commit 55a052481d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -336,7 +336,6 @@ pkg/volume/csi/fake
pkg/volume/git_repo pkg/volume/git_repo
pkg/volume/host_path pkg/volume/host_path
pkg/volume/iscsi pkg/volume/iscsi
pkg/volume/nfs
pkg/volume/photon_pd pkg/volume/photon_pd
pkg/volume/rbd pkg/volume/rbd
pkg/volume/scaleio pkg/volume/scaleio

View File

@ -32,7 +32,7 @@ import (
utilstrings "k8s.io/utils/strings" utilstrings "k8s.io/utils/strings"
) )
// This is the primary entrypoint for volume plugins. // ProbeVolumePlugins is the primary entrypoint for volume plugins.
// The volumeConfig arg provides the ability to configure recycler behavior. It is implemented as a pointer to allow nils. // The volumeConfig arg provides the ability to configure recycler behavior. It is implemented as a pointer to allow nils.
// The nfsPlugin is used to store the volumeConfig and give it, when needed, to the func that creates NFS Recyclers. // The nfsPlugin is used to store the volumeConfig and give it, when needed, to the func that creates NFS Recyclers.
// Tests that exercise recycling should not use this func but instead use ProbeRecyclablePlugins() to override default behavior. // Tests that exercise recycling should not use this func but instead use ProbeRecyclablePlugins() to override default behavior.
@ -224,21 +224,21 @@ type nfsMounter struct {
var _ volume.Mounter = &nfsMounter{} var _ volume.Mounter = &nfsMounter{}
func (b *nfsMounter) GetAttributes() volume.Attributes { func (nfsMounter *nfsMounter) GetAttributes() volume.Attributes {
return volume.Attributes{ return volume.Attributes{
ReadOnly: b.readOnly, ReadOnly: nfsMounter.readOnly,
Managed: false, Managed: false,
SupportsSELinux: false, SupportsSELinux: false,
} }
} }
// SetUp attaches the disk and bind mounts to the volume path. // SetUp attaches the disk and bind mounts to the volume path.
func (b *nfsMounter) SetUp(fsGroup *int64) error { func (nfsMounter *nfsMounter) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup) return nfsMounter.SetUpAt(nfsMounter.GetPath(), fsGroup)
} }
func (b *nfsMounter) SetUpAt(dir string, fsGroup *int64) error { func (nfsMounter *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := mount.IsNotMountPoint(b.mounter, dir) notMnt, err := mount.IsNotMountPoint(nfsMounter.mounter, dir)
klog.V(4).Infof("NFS mount set up: %s %v %v", dir, !notMnt, err) klog.V(4).Infof("NFS mount set up: %s %v %v", dir, !notMnt, err)
if err != nil && !os.IsNotExist(err) { if err != nil && !os.IsNotExist(err) {
return err return err
@ -249,25 +249,25 @@ func (b *nfsMounter) SetUpAt(dir string, fsGroup *int64) error {
if err := os.MkdirAll(dir, 0750); err != nil { if err := os.MkdirAll(dir, 0750); err != nil {
return err return err
} }
source := fmt.Sprintf("%s:%s", b.server, b.exportPath) source := fmt.Sprintf("%s:%s", nfsMounter.server, nfsMounter.exportPath)
options := []string{} options := []string{}
if b.readOnly { if nfsMounter.readOnly {
options = append(options, "ro") options = append(options, "ro")
} }
mountOptions := util.JoinMountOptions(b.mountOptions, options) mountOptions := util.JoinMountOptions(nfsMounter.mountOptions, options)
err = b.mounter.Mount(source, dir, "nfs", mountOptions) err = nfsMounter.mounter.Mount(source, dir, "nfs", mountOptions)
if err != nil { if err != nil {
notMnt, mntErr := mount.IsNotMountPoint(b.mounter, dir) notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
if mntErr != nil { if mntErr != nil {
klog.Errorf("IsNotMountPoint check failed: %v", mntErr) klog.Errorf("IsNotMountPoint check failed: %v", mntErr)
return err return err
} }
if !notMnt { if !notMnt {
if mntErr = b.mounter.Unmount(dir); mntErr != nil { if mntErr = nfsMounter.mounter.Unmount(dir); mntErr != nil {
klog.Errorf("Failed to unmount: %v", mntErr) klog.Errorf("Failed to unmount: %v", mntErr)
return err return err
} }
notMnt, mntErr := mount.IsNotMountPoint(b.mounter, dir) notMnt, mntErr := mount.IsNotMountPoint(nfsMounter.mounter, dir)
if mntErr != nil { if mntErr != nil {
klog.Errorf("IsNotMountPoint check failed: %v", mntErr) klog.Errorf("IsNotMountPoint check failed: %v", mntErr)
return err return err