@@ -17,21 +17,27 @@ limitations under the License.
1717package nfs
1818
1919import (
20- "fmt"
21-
2220 "github.com/container-storage-interface/spec/lib/go/csi"
2321 "k8s.io/klog/v2"
2422 mount "k8s.io/mount-utils"
2523)
2624
27- type Driver struct {
28- name string
29- nodeID string
30- version string
31-
32- endpoint string
25+ // DriverOptions defines driver parameters specified in driver deployment
26+ type DriverOptions struct {
27+ NodeID string
28+ DriverName string
29+ Endpoint string
30+ MountPermissions uint64
31+ WorkingMountDir string
32+ }
3333
34- perm * uint32
34+ type Driver struct {
35+ name string
36+ nodeID string
37+ version string
38+ endpoint string
39+ mountPermissions uint64
40+ workingMountDir string
3541
3642 //ids *identityServer
3743 ns * NodeServer
@@ -53,16 +59,17 @@ const (
5359 mountOptionsField = "mountoptions"
5460)
5561
56- func NewDriver (nodeID , driverName , endpoint string , perm * uint32 ) * Driver {
57- klog .V (2 ).Infof ("Driver: %v version: %v" , driverName , driverVersion )
62+ func NewDriver (options * DriverOptions ) * Driver {
63+ klog .V (2 ).Infof ("Driver: %v version: %v" , options . DriverName , driverVersion )
5864
5965 n := & Driver {
60- name : driverName ,
61- version : driverVersion ,
62- nodeID : nodeID ,
63- endpoint : endpoint ,
64- cap : map [csi.VolumeCapability_AccessMode_Mode ]bool {},
65- perm : perm ,
66+ name : options .DriverName ,
67+ version : driverVersion ,
68+ nodeID : options .NodeID ,
69+ endpoint : options .Endpoint ,
70+ mountPermissions : options .MountPermissions ,
71+ workingMountDir : options .WorkingMountDir ,
72+ cap : map [csi.VolumeCapability_AccessMode_Mode ]bool {},
6673 }
6774
6875 vcam := []csi.VolumeCapability_AccessMode_Mode {
@@ -102,7 +109,7 @@ func (n *Driver) Run(testMode bool) {
102109 if err != nil {
103110 klog .Fatalf ("%v" , err )
104111 }
105- klog .Infof ("\n DRIVER INFORMATION:\n -------------------\n %s\n \n Streaming logs below:" , versionMeta )
112+ klog .V ( 2 ). Infof ("\n DRIVER INFORMATION:\n -------------------\n %s\n \n Streaming logs below:" , versionMeta )
106113
107114 n .ns = NewNodeServer (n , mount .New ("" ))
108115 s := NewNonBlockingGRPCServer ()
@@ -119,7 +126,6 @@ func (n *Driver) Run(testMode bool) {
119126func (n * Driver ) AddVolumeCapabilityAccessModes (vc []csi.VolumeCapability_AccessMode_Mode ) []* csi.VolumeCapability_AccessMode {
120127 var vca []* csi.VolumeCapability_AccessMode
121128 for _ , c := range vc {
122- klog .Infof ("Enabling volume access mode: %v" , c .String ())
123129 vca = append (vca , & csi.VolumeCapability_AccessMode {Mode : c })
124130 n .cap [c ] = true
125131 }
@@ -128,26 +134,21 @@ func (n *Driver) AddVolumeCapabilityAccessModes(vc []csi.VolumeCapability_Access
128134
129135func (n * Driver ) AddControllerServiceCapabilities (cl []csi.ControllerServiceCapability_RPC_Type ) {
130136 var csc []* csi.ControllerServiceCapability
131-
132137 for _ , c := range cl {
133- klog .Infof ("Enabling controller service capability: %v" , c .String ())
134138 csc = append (csc , NewControllerServiceCapability (c ))
135139 }
136-
137140 n .cscap = csc
138141}
139142
140143func (n * Driver ) AddNodeServiceCapabilities (nl []csi.NodeServiceCapability_RPC_Type ) {
141144 var nsc []* csi.NodeServiceCapability
142145 for _ , n := range nl {
143- klog .Infof ("Enabling node service capability: %v" , n .String ())
144146 nsc = append (nsc , NewNodeServiceCapability (n ))
145147 }
146148 n .nscap = nsc
147149}
148150
149151func IsCorruptedDir (dir string ) bool {
150152 _ , pathErr := mount .PathExists (dir )
151- fmt .Printf ("IsCorruptedDir(%s) returned with error: %v" , dir , pathErr )
152153 return pathErr != nil && mount .IsCorruptedMnt (pathErr )
153154}
0 commit comments