Merge pull request #70613 from jianglingxia/jlx201811031619

fix golint problem of volume cephfs/iscsi/nfs
pull/564/head
k8s-ci-robot 2018-11-29 02:01:13 -08:00 committed by GitHub
commit d0e8e6b78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 33 deletions

View File

@ -262,17 +262,17 @@ func (plugin *iscsiPlugin) ConstructBlockVolumeSpec(podUID types.UID, volumeName
} }
type iscsiDisk struct { type iscsiDisk struct {
VolName string VolName string
podUID types.UID podUID types.UID
Portals []string Portals []string
Iqn string Iqn string
Lun string Lun string
Iface string Iface string
chap_discovery bool chapDiscovery bool
chap_session bool chapSession bool
secret map[string]string secret map[string]string
InitiatorName string InitiatorName string
plugin *iscsiPlugin plugin *iscsiPlugin
// Utility interface that provides API calls to the provider to attach/detach disks. // Utility interface that provides API calls to the provider to attach/detach disks.
manager diskManager manager diskManager
volume.MetricsProvider volume.MetricsProvider
@ -539,18 +539,18 @@ func createISCSIDisk(spec *volume.Spec, podUID types.UID, plugin *iscsiPlugin, m
} }
return &iscsiDisk{ return &iscsiDisk{
podUID: podUID, podUID: podUID,
VolName: spec.Name(), VolName: spec.Name(),
Portals: bkportal, Portals: bkportal,
Iqn: iqn, Iqn: iqn,
Lun: lun, Lun: lun,
Iface: iface, Iface: iface,
chap_discovery: chapDiscovery, chapDiscovery: chapDiscovery,
chap_session: chapSession, chapSession: chapSession,
secret: secret, secret: secret,
InitiatorName: initiatorName, InitiatorName: initiatorName,
manager: manager, manager: manager,
plugin: plugin}, nil plugin: plugin}, nil
} }
func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) (map[string]string, error) { func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) (map[string]string, error) {

View File

@ -54,12 +54,12 @@ const (
) )
var ( var (
chap_st = []string{ chapSt = []string{
"discovery.sendtargets.auth.username", "discovery.sendtargets.auth.username",
"discovery.sendtargets.auth.password", "discovery.sendtargets.auth.password",
"discovery.sendtargets.auth.username_in", "discovery.sendtargets.auth.username_in",
"discovery.sendtargets.auth.password_in"} "discovery.sendtargets.auth.password_in"}
chap_sess = []string{ chapSess = []string{
"node.session.auth.username", "node.session.auth.username",
"node.session.auth.password", "node.session.auth.password",
"node.session.auth.username_in", "node.session.auth.username_in",
@ -69,7 +69,7 @@ var (
) )
func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error { func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
if !b.chap_discovery { if !b.chapDiscovery {
return nil 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") out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", "discovery.sendtargets.auth.authmethod", "-v", "CHAP")
@ -77,7 +77,7 @@ func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
return fmt.Errorf("iscsi: failed to update discoverydb with CHAP, output: %v", string(out)) 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] v := b.secret[k]
if len(v) > 0 { 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) out, err := b.exec.Run("iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
@ -90,7 +90,7 @@ func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
} }
func updateISCSINode(b iscsiDiskMounter, tp string) error { func updateISCSINode(b iscsiDiskMounter, tp string) error {
if !b.chap_session { if !b.chapSession {
return nil return nil
} }
@ -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)) 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] v := b.secret[k]
if len(v) > 0 { 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) out, err := b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "-o", "update", "-n", k, "-v", v)
@ -210,7 +210,7 @@ func (util *ISCSIUtil) persistISCSI(conf iscsiDisk, mnt string) error {
defer fp.Close() defer fp.Close()
encoder := json.NewEncoder(fp) encoder := json.NewEncoder(fp)
if err = encoder.Encode(conf); err != nil { 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 return nil
} }
@ -224,7 +224,7 @@ func (util *ISCSIUtil) loadISCSI(conf *iscsiDisk, mnt string) error {
defer fp.Close() defer fp.Close()
decoder := json.NewDecoder(fp) decoder := json.NewDecoder(fp)
if err = decoder.Decode(conf); err != nil { 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 return nil
} }

View File

@ -89,8 +89,8 @@ func TestRecycler(t *testing.T) {
plugMgr.InitPlugins([]volume.VolumePlugin{&nfsPlugin{nil, volume.VolumeConfig{}}}, nil, volumetest.NewFakeVolumeHost(tmpDir, nil, nil)) 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"}}}}} spec := &volume.Spec{PersistentVolume: &v1.PersistentVolume{Spec: v1.PersistentVolumeSpec{PersistentVolumeSource: v1.PersistentVolumeSource{NFS: &v1.NFSVolumeSource{Path: "/foo"}}}}}
_, plugin_err := plugMgr.FindRecyclablePluginBySpec(spec) _, pluginErr := plugMgr.FindRecyclablePluginBySpec(spec)
if plugin_err != nil { if pluginErr != nil {
t.Errorf("Can't find the plugin by name") t.Errorf("Can't find the plugin by name")
} }
} }