diff --git a/cephfs/main.go b/cephfs/main.go index 92f2c0ceb..3d54b87c4 100644 --- a/cephfs/main.go +++ b/cephfs/main.go @@ -57,7 +57,7 @@ func main() { os.Exit(1) } - driver := cephfs.NewCephFSDriver() + driver := cephfs.NewDriver() driver.Run(*driverName, *nodeID, *endpoint, *volumeMounter, cp) os.Exit(0) diff --git a/pkg/cephfs/driver.go b/pkg/cephfs/driver.go index f830b1597..24897cf43 100644 --- a/pkg/cephfs/driver.go +++ b/pkg/cephfs/driver.go @@ -30,8 +30,8 @@ const ( Version = "1.0.0" ) -type cephfsDriver struct { - driver *csicommon.CSIDriver +type driver struct { + cd *csicommon.CSIDriver is *identityServer ns *nodeServer @@ -39,12 +39,12 @@ type cephfsDriver struct { } var ( - driver *cephfsDriver + cephDriver *driver DefaultVolumeMounter string ) -func NewCephFSDriver() *cephfsDriver { - return &cephfsDriver{} +func NewDriver() *driver { + return &driver{} } func NewIdentityServer(d *csicommon.CSIDriver) *identityServer { @@ -66,7 +66,7 @@ func NewNodeServer(d *csicommon.CSIDriver) *nodeServer { } } -func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) { +func (fs *driver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) { glog.Infof("Driver: %v version: %v", driverName, Version) // Configuration @@ -92,25 +92,25 @@ func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string, // Initialize default library driver - fs.driver = csicommon.NewCSIDriver(driverName, Version, nodeId) - if fs.driver == nil { + fs.cd = csicommon.NewCSIDriver(driverName, Version, nodeId) + if fs.cd == nil { glog.Fatalln("Failed to initialize CSI driver") } - fs.driver.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ + fs.cd.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, }) - fs.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{ + fs.cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{ csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, }) // Create gRPC servers - fs.is = NewIdentityServer(fs.driver) - fs.ns = NewNodeServer(fs.driver) + fs.is = NewIdentityServer(fs.cd) + fs.ns = NewNodeServer(fs.cd) - fs.cs = NewControllerServer(fs.driver, cachePersister) + fs.cs = NewControllerServer(fs.cd, cachePersister) server := csicommon.NewNonBlockingGRPCServer() server.Start(endpoint, fs.is, fs.cs, fs.ns) diff --git a/pkg/rbd/rbd.go b/pkg/rbd/rbd.go index e5451a260..66b4a307e 100644 --- a/pkg/rbd/rbd.go +++ b/pkg/rbd/rbd.go @@ -35,8 +35,8 @@ const ( rbdDefaultUserID = rbdDefaultAdminID ) -type rbd struct { - driver *csicommon.CSIDriver +type driver struct { + cd *csicommon.CSIDriver ids *identityServer ns *nodeServer @@ -47,8 +47,8 @@ var ( version = "1.0.0" ) -func GetRBDDriver() *rbd { - return &rbd{} +func GetDriver() *driver { + return &driver{} } func NewIdentityServer(d *csicommon.CSIDriver) *identityServer { @@ -79,34 +79,34 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*nodeServer, err }, nil } -func (rbd *rbd) Run(driverName, nodeID, endpoint string, containerized bool, cachePersister util.CachePersister) { +func (r *driver) Run(driverName, nodeID, endpoint string, containerized bool, cachePersister util.CachePersister) { var err error glog.Infof("Driver: %v version: %v", driverName, version) // Initialize default library driver - rbd.driver = csicommon.NewCSIDriver(driverName, version, nodeID) - if rbd.driver == nil { + r.cd = csicommon.NewCSIDriver(driverName, version, nodeID) + if r.cd == nil { glog.Fatalln("Failed to initialize CSI Driver.") } - rbd.driver.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ + r.cd.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{ csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, }) - rbd.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER}) + r.cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER}) // Create GRPC servers - rbd.ids = NewIdentityServer(rbd.driver) - rbd.ns, err = NewNodeServer(rbd.driver, containerized) + r.ids = NewIdentityServer(r.cd) + r.ns, err = NewNodeServer(r.cd, containerized) if err != nil { glog.Fatalf("failed to start node server, err %v\n", err) } - rbd.cs = NewControllerServer(rbd.driver, cachePersister) - rbd.cs.LoadExDataFromMetadataStore() + r.cs = NewControllerServer(r.cd, cachePersister) + r.cs.LoadExDataFromMetadataStore() s := csicommon.NewNonBlockingGRPCServer() - s.Start(endpoint, rbd.ids, rbd.cs, rbd.ns) + s.Start(endpoint, r.ids, r.cs, r.ns) s.Wait() } diff --git a/rbd/main.go b/rbd/main.go index 2031245e0..86346ed12 100644 --- a/rbd/main.go +++ b/rbd/main.go @@ -56,7 +56,7 @@ func main() { os.Exit(1) } - driver := rbd.GetRBDDriver() + driver := rbd.GetDriver() driver.Run(*driverName, *nodeID, *endpoint, *containerized, cp) os.Exit(0)