Skip to content

Commit

Permalink
Merge pull request #10 from humblec/fields
Browse files Browse the repository at this point in the history
Correct/use better struct fields/variables in iscsi driver
  • Loading branch information
k8s-ci-robot committed Mar 26, 2019
2 parents 93379ae + 47fffd9 commit 662398f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions pkg/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ func getISCSIInfo(req *csi.NodePublishVolumeRequest) (*iscsiDisk, error) {
}

return &iscsiDisk{
VolName: volName,
Portals: bkportal,
Iqn: iqn,
lun: lun,
Iface: iface,
chap_discovery: chapDiscovery,
chap_session: chapSession,
secret: secret,
InitiatorName: initiatorName}, nil
VolName: volName,
Portals: bkportal,
Iqn: iqn,
lun: lun,
Iface: iface,
chapDiscovery: chapDiscovery,
chapSession: chapSession,
secret: secret,
InitiatorName: initiatorName}, nil
}

func getISCSIDiskMounter(iscsiInfo *iscsiDisk, req *csi.NodePublishVolumeRequest) *iscsiDiskMounter {
Expand Down Expand Up @@ -119,15 +119,15 @@ func parseSecret(secretParams string) map[string]string {
}

type iscsiDisk struct {
Portals []string
Iqn string
lun string
Iface string
chap_discovery bool
chap_session bool
secret map[string]string
InitiatorName string
VolName string
Portals []string
Iqn string
lun string
Iface string
chapDiscovery bool
chapSession bool
secret map[string]string
InitiatorName string
VolName string
}

type iscsiDiskMounter struct {
Expand Down
16 changes: 8 additions & 8 deletions pkg/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import (
)

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 @@ -46,15 +46,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 @@ -67,7 +67,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 @@ -76,7 +76,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 @@ -143,7 +143,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 @@ -158,7 +158,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

0 comments on commit 662398f

Please sign in to comment.