Skip to content

Commit

Permalink
Merge pull request #51 from humblec/cm-1
Browse files Browse the repository at this point in the history
Rename iscsi_lib to iscsiLib to avoid snake case import
  • Loading branch information
k8s-ci-robot authored May 17, 2021
2 parents 249e36a + 8a3deec commit 4581c41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
40 changes: 20 additions & 20 deletions pkg/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"

"github.com/container-storage-interface/spec/lib/go/csi"
iscsi_lib "github.com/kubernetes-csi/csi-lib-iscsi/iscsi"
iscsiLib "github.com/kubernetes-csi/csi-lib-iscsi/iscsi"
"k8s.io/kubernetes/pkg/volume/util"
"k8s.io/utils/exec"
"k8s.io/utils/mount"
Expand Down Expand Up @@ -98,17 +98,17 @@ func getISCSIInfo(req *csi.NodePublishVolumeRequest) (*iscsiDisk, error) {
InitiatorName: initiatorName}, nil
}

func buildISCSIConnector(iscsiInfo *iscsiDisk) *iscsi_lib.Connector {
c := iscsi_lib.Connector{
func buildISCSIConnector(iscsiInfo *iscsiDisk) *iscsiLib.Connector {
c := iscsiLib.Connector{
VolumeName: iscsiInfo.VolName,
TargetIqn: iscsiInfo.Iqn,
TargetPortals: iscsiInfo.Portals,
Multipath: len(iscsiInfo.Portals) > 1,
}

if iscsiInfo.sessionSecret != (iscsi_lib.Secrets{}) {
if iscsiInfo.sessionSecret != (iscsiLib.Secrets{}) {
c.SessionSecrets = iscsiInfo.sessionSecret
if iscsiInfo.discoverySecret != (iscsi_lib.Secrets{}) {
if iscsiInfo.discoverySecret != (iscsiLib.Secrets{}) {
c.DiscoverySecrets = iscsiInfo.discoverySecret
}
}
Expand Down Expand Up @@ -159,50 +159,50 @@ func parseSecret(secretParams string) map[string]string {
return secret
}

func parseSessionSecret(secretParams map[string]string) (iscsi_lib.Secrets, error) {
func parseSessionSecret(secretParams map[string]string) (iscsiLib.Secrets, error) {
var ok bool
secret := iscsi_lib.Secrets{}
secret := iscsiLib.Secrets{}

if len(secretParams) == 0 {
return secret, nil
}

if secret.UserName, ok = secretParams["node.session.auth.username"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.session.auth.username not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.session.auth.username not found in secret")
}
if secret.Password, ok = secretParams["node.session.auth.password"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.session.auth.password not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.session.auth.password not found in secret")
}
if secret.UserNameIn, ok = secretParams["node.session.auth.username_in"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.session.auth.username_in not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.session.auth.username_in not found in secret")
}
if secret.PasswordIn, ok = secretParams["node.session.auth.password_in"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.session.auth.password_in not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.session.auth.password_in not found in secret")
}

secret.SecretsType = "chap"
return secret, nil
}

func parseDiscoverySecret(secretParams map[string]string) (iscsi_lib.Secrets, error) {
func parseDiscoverySecret(secretParams map[string]string) (iscsiLib.Secrets, error) {
var ok bool
secret := iscsi_lib.Secrets{}
secret := iscsiLib.Secrets{}

if len(secretParams) == 0 {
return secret, nil
}

if secret.UserName, ok = secretParams["node.sendtargets.auth.username"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.sendtargets.auth.username not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.sendtargets.auth.username not found in secret")
}
if secret.Password, ok = secretParams["node.sendtargets.auth.password"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.sendtargets.auth.password not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.sendtargets.auth.password not found in secret")
}
if secret.UserNameIn, ok = secretParams["node.sendtargets.auth.username_in"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.sendtargets.auth.username_in not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.sendtargets.auth.username_in not found in secret")
}
if secret.PasswordIn, ok = secretParams["node.sendtargets.auth.password_in"]; !ok {
return iscsi_lib.Secrets{}, fmt.Errorf("node.sendtargets.auth.password_in not found in secret")
return iscsiLib.Secrets{}, fmt.Errorf("node.sendtargets.auth.password_in not found in secret")
}

secret.SecretsType = "chap"
Expand All @@ -217,8 +217,8 @@ type iscsiDisk struct {
chapDiscovery bool
chapSession bool
secret map[string]string
sessionSecret iscsi_lib.Secrets
discoverySecret iscsi_lib.Secrets
sessionSecret iscsiLib.Secrets
discoverySecret iscsiLib.Secrets
InitiatorName string
VolName string
}
Expand All @@ -232,7 +232,7 @@ type iscsiDiskMounter struct {
exec exec.Interface
deviceUtil util.DeviceUtil
targetPath string
connector *iscsi_lib.Connector
connector *iscsiLib.Connector
}

type iscsiDiskUnmounter struct {
Expand Down
10 changes: 5 additions & 5 deletions pkg/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import (
"os"
"path"

iscsi_lib "github.com/kubernetes-csi/csi-lib-iscsi/iscsi"
iscsiLib "github.com/kubernetes-csi/csi-lib-iscsi/iscsi"
"k8s.io/klog/v2"
"k8s.io/utils/mount"
)

type ISCSIUtil struct{}

func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
devicePath, err := iscsi_lib.Connect(*b.connector)
devicePath, err := iscsiLib.Connect(*b.connector)
if err != nil {
return "", err
}
Expand All @@ -55,7 +55,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {

// Persist iscsi disk config to json file for DetachDisk path
file := path.Join(mntPath, b.VolName+".json")
err = iscsi_lib.PersistConnector(b.connector, file)
err = iscsiLib.PersistConnector(b.connector, file)
if err != nil {
klog.Errorf("failed to persist connection info: %v", err)
klog.Errorf("disconnecting volume and failing the publish request because persistence files are required for reliable Unpublish")
Expand Down Expand Up @@ -103,13 +103,13 @@ func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, targetPath string) error

// load iscsi disk config from json file
file := path.Join(targetPath, c.iscsiDisk.VolName+".json")
connector, err := iscsi_lib.GetConnectorFromFile(file)
connector, err := iscsiLib.GetConnectorFromFile(file)
if err != nil {
klog.Errorf("iscsi detach disk: failed to get iscsi config from path %s Error: %v", targetPath, err)
return err
}

iscsi_lib.Disconnect(connector.TargetIqn, connector.TargetPortals)
iscsiLib.Disconnect(connector.TargetIqn, connector.TargetPortals)

if err := os.RemoveAll(targetPath); err != nil {
klog.Errorf("iscsi: failed to remove mount path Error: %v", err)
Expand Down

0 comments on commit 4581c41

Please sign in to comment.