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

Rename iscsi_lib to iscsiLib to avoid snake case import #51

Merged
merged 1 commit into from
May 17, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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