Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix golint problem of volume cephfs/iscsi/nfs #70613

Merged
merged 2 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 23 additions & 23 deletions pkg/volume/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ func (plugin *iscsiPlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeName
}

type iscsiDisk struct {
VolName string
podUID types.UID
Portals []string
Iqn string
Lun string
Iface string
chap_discovery bool
chap_session bool
secret map[string]string
InitiatorName string
plugin *iscsiPlugin
VolName string
podUID types.UID
Portals []string
Iqn string
Lun string
Iface string
chapDiscovery bool
chapSession bool
secret map[string]string
InitiatorName string
plugin *iscsiPlugin
// Utility interface that provides API calls to the provider to attach/detach disks.
manager diskManager
volume.MetricsProvider
Expand Down Expand Up @@ -539,18 +539,18 @@ func createISCSIDisk(spec *volume.Spec, podUID types.UID, plugin *iscsiPlugin, m
}

return &iscsiDisk{
podUID: podUID,
VolName: spec.Name(),
Portals: bkportal,
Iqn: iqn,
Lun: lun,
Iface: iface,
chap_discovery: chapDiscovery,
chap_session: chapSession,
secret: secret,
InitiatorName: initiatorName,
manager: manager,
plugin: plugin}, nil
podUID: podUID,
VolName: spec.Name(),
Portals: bkportal,
Iqn: iqn,
Lun: lun,
Iface: iface,
chapDiscovery: chapDiscovery,
chapSession: chapSession,
secret: secret,
InitiatorName: initiatorName,
manager: manager,
plugin: plugin}, nil
}

func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) (map[string]string, error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/volume/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ const (
)

var (
chap_st = []string{
chapSt = []string{
"discovery.sendtargets.auth.username",
"discovery.sendtargets.auth.password",
"discovery.sendtargets.auth.username_in",
"discovery.sendtargets.auth.password_in"}
chap_sess = []string{
chapSess = []string{
"node.session.auth.username",
"node.session.auth.password",
"node.session.auth.username_in",
Expand All @@ -69,15 +69,15 @@ var (
)

func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
if !b.chap_discovery {
if !b.chapDiscovery {
return nil
}
out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", "discovery.sendtargets.auth.authmethod", "-v", "CHAP")
if err != nil {
return fmt.Errorf("iscsi: failed to update discoverydb with CHAP, output: %v", string(out))
}

for _, k := range chap_st {
for _, k := range chapSt {
v := b.secret[k]
if len(v) > 0 {
out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
Expand All @@ -90,7 +90,7 @@ func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
}

func updateISCSINode(b iscsiDiskMounter, tp string) error {
if !b.chap_session {
if !b.chapSession {
return nil
}

Expand All @@ -99,7 +99,7 @@ func updateISCSINode(b iscsiDiskMounter, tp string) error {
return fmt.Errorf("iscsi: failed to update node with CHAP, output: %v", string(out))
}

for _, k := range chap_sess {
for _, k := range chapSess {
v := b.secret[k]
if len(v) > 0 {
out, err := b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
Expand Down Expand Up @@ -210,7 +210,7 @@ func (util *ISCSIUtil) persistISCSI(conf iscsiDisk, mnt string) error {
defer fp.Close()
encoder := json.NewEncoder(fp)
if err = encoder.Encode(conf); err != nil {
return fmt.Errorf("iscsi: encode err: %v.", err)
return fmt.Errorf("iscsi: encode err: %v", err)
}
return nil
}
Expand All @@ -224,7 +224,7 @@ func (util *ISCSIUtil) loadISCSI(conf *iscsiDisk, mnt string) error {
defer fp.Close()
decoder := json.NewDecoder(fp)
if err = decoder.Decode(conf); err != nil {
return fmt.Errorf("iscsi: decode err: %v.", err)
return fmt.Errorf("iscsi: decode err: %v", err)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/volume/nfs/nfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func TestRecycler(t *testing.T) {
plugMgr.InitPlugins([]volume.VolumePlugin{&nfsPlugin{nil, volume.VolumeConfig{}}}, nil, volumetest.NewFakeVolumeHost(tmpDir, nil, nil))

spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{NFS: &v1.NFSVolumeSource{Path: "/foo"}}}}}
_, plugin_err := plugMgr.FindRecyclablePluginBySpec(spec)
if plugin_err != nil {
_, pluginErr := plugMgr.FindRecyclablePluginBySpec(spec)
if pluginErr != nil {
t.Errorf("Can't find the plugin by name")
}
}
Expand Down