Skip to content

Commit

Permalink
feat: add --drivername=.. option for alternative driver deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpanic committed May 11, 2021
1 parent cf03da6 commit c5f45b3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/smb/smb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

const (
DriverName = "smb.csi.k8s.io"
DefaultDriverName = "smb.csi.k8s.io"
createSubDirField = "createsubdir"
)

Expand All @@ -44,9 +44,9 @@ type Driver struct {

// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
// does not support optional driver plugin info manifest field. Refer to CSI spec for more details.
func NewDriver(nodeID string) *Driver {
func NewDriver(nodeID, driverName string) *Driver {
driver := Driver{}
driver.Name = DriverName
driver.Name = driverName
driver.Version = driverVersion
driver.NodeID = nodeID
driver.volumeLocks = newVolumeLocks()
Expand Down
4 changes: 2 additions & 2 deletions pkg/smb/smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const (
)

func NewFakeDriver() *Driver {
return NewDriver(fakeNodeID)
return NewDriver(fakeNodeID, DefaultDriverName)
}

func TestNewFakeDriver(t *testing.T) {
// Test New fake driver.
d := NewDriver(fakeNodeID)
d := NewDriver(fakeNodeID, DefaultDriverName)
assert.NotNil(t, d)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/smb/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type VersionInfo struct {
// GetVersion returns the version information of the driver
func GetVersion() VersionInfo {
return VersionInfo{
DriverName: DriverName,
DriverName: DefaultDriverName,
DriverVersion: driverVersion,
GitCommit: gitCommit,
BuildDate: buildDate,
Expand Down
2 changes: 1 addition & 1 deletion pkg/smb/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestGetVersion(t *testing.T) {
version := GetVersion()

expected := VersionInfo{
DriverName: DriverName,
DriverName: DefaultDriverName,
DriverVersion: "N/A",
GitCommit: "N/A",
BuildDate: "N/A",
Expand Down
3 changes: 2 additions & 1 deletion pkg/smbplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func init() {
var (
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
nodeID = flag.String("nodeid", "", "node id")
driverName = flag.String("drivername", smb.DefaultDriverName, "name of the driver")
version = flag.Bool("version", false, "Print the version and exit.")
metricsAddress = flag.String("metrics-address", "0.0.0.0:29644", "export the metrics")
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
Expand All @@ -63,7 +64,7 @@ func main() {
}

func handle() {
driver := smb.NewDriver(*nodeID)
driver := smb.NewDriver(*nodeID, *driverName)
if driver == nil {
klog.Fatalln("Failed to initialize smb CSI Driver")
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/driver/smb_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type SMBDriver struct {
func InitSMBDriver() PVTestDriver {
driverName := os.Getenv(SMBDriverNameVar)
if driverName == "" {
driverName = smb.DriverName
driverName = smb.DefaultDriverName
}

klog.Infof("Using smb driver: %s", driverName)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var _ = ginkgo.BeforeSuite(func() {

nodeid := os.Getenv("nodeid")
kubeconfig := os.Getenv(kubeconfigEnvVar)
smbDriver = smb.NewDriver(nodeid)
smbDriver = smb.NewDriver(nodeid, smb.DefaultDriverName)
go func() {
smbDriver.Run(fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String()), kubeconfig, false)
}()
Expand Down

0 comments on commit c5f45b3

Please sign in to comment.