@@ -38,9 +38,23 @@ import (
3838 utilexec "k8s.io/utils/exec"
3939)
4040
41- var _ mount.Interface = & CSIProxyMounter {}
41+ // CSIProxyMounter extends the mount.Interface interface with CSI Proxy methods.
42+ type CSIProxyMounter interface {
43+ mount.Interface
44+
45+ SMBMount (source , target , fsType string , mountOptions , sensitiveMountOptions []string ) error
46+ SMBUnmount (target string ) error
47+ MakeDir (path string ) error
48+ Rmdir (path string ) error
49+ IsMountPointMatch (mp mount.MountPoint , dir string ) bool
50+ ExistsPath (path string ) (bool , error )
51+ GetAPIVersions () string
52+ EvalHostSymlinks (pathname string ) (string , error )
53+ }
54+
55+ var _ CSIProxyMounter = & csiProxyMounter {}
4256
43- type CSIProxyMounter struct {
57+ type csiProxyMounter struct {
4458 FsClient * fsclient.Client
4559 SMBClient * smbclient.Client
4660}
@@ -53,7 +67,7 @@ func normalizeWindowsPath(path string) string {
5367 return normalizedPath
5468}
5569
56- func (mounter * CSIProxyMounter ) SMBMount (source , target , fsType string , mountOptions , sensitiveMountOptions []string ) error {
70+ func (mounter * csiProxyMounter ) SMBMount (source , target , fsType string , mountOptions , sensitiveMountOptions []string ) error {
5771 klog .V (4 ).Infof ("SMBMount: remote path: %s. local path: %s" , source , target )
5872
5973 if len (mountOptions ) == 0 || len (sensitiveMountOptions ) == 0 {
@@ -99,15 +113,15 @@ func (mounter *CSIProxyMounter) SMBMount(source, target, fsType string, mountOpt
99113 return nil
100114}
101115
102- func (mounter * CSIProxyMounter ) SMBUnmount (target string ) error {
116+ func (mounter * csiProxyMounter ) SMBUnmount (target string ) error {
103117 klog .V (4 ).Infof ("SMBUnmount: local path: %s" , target )
104118 // TODO: We need to remove the SMB mapping. The change to remove the
105119 // directory brings the CSI code in parity with the in-tree.
106120 return mounter .Rmdir (target )
107121}
108122
109123// Mount just creates a soft link at target pointing to source.
110- func (mounter * CSIProxyMounter ) Mount (source string , target string , fstype string , options []string ) error {
124+ func (mounter * csiProxyMounter ) Mount (source string , target string , fstype string , options []string ) error {
111125 klog .V (4 ).Infof ("Mount: old name: %s. new name: %s" , source , target )
112126 // Mount is called after the format is done.
113127 // TODO: Confirm that fstype is empty.
@@ -130,7 +144,7 @@ func Split(r rune) bool {
130144// TODO: Call separate rmdir for pod context and plugin context. v1alpha1 for CSI
131145// proxy does a relaxed check for prefix as c:\var\lib\kubelet, so we can do
132146// rmdir with either pod or plugin context.
133- func (mounter * CSIProxyMounter ) Rmdir (path string ) error {
147+ func (mounter * csiProxyMounter ) Rmdir (path string ) error {
134148 klog .V (4 ).Infof ("Remove directory: %s" , path )
135149 rmdirRequest := & fs.RmdirRequest {
136150 Path : normalizeWindowsPath (path ),
@@ -144,23 +158,23 @@ func (mounter *CSIProxyMounter) Rmdir(path string) error {
144158}
145159
146160// Unmount - Removes the directory - equivalent to unmount on Linux.
147- func (mounter * CSIProxyMounter ) Unmount (target string ) error {
161+ func (mounter * csiProxyMounter ) Unmount (target string ) error {
148162 klog .V (4 ).Infof ("Unmount: %s" , target )
149163 return mounter .Rmdir (target )
150164}
151165
152- func (mounter * CSIProxyMounter ) List () ([]mount.MountPoint , error ) {
166+ func (mounter * csiProxyMounter ) List () ([]mount.MountPoint , error ) {
153167 return []mount.MountPoint {}, fmt .Errorf ("List not implemented for CSIProxyMounter" )
154168}
155169
156- func (mounter * CSIProxyMounter ) IsMountPointMatch (mp mount.MountPoint , dir string ) bool {
170+ func (mounter * csiProxyMounter ) IsMountPointMatch (mp mount.MountPoint , dir string ) bool {
157171 return mp .Path == dir
158172}
159173
160174// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error.
161175// If the path exists, call to CSI proxy will check if its a link, if its a link then existence of target
162176// path is checked.
163- func (mounter * CSIProxyMounter ) IsLikelyNotMountPoint (path string ) (bool , error ) {
177+ func (mounter * csiProxyMounter ) IsLikelyNotMountPoint (path string ) (bool , error ) {
164178 klog .V (4 ).Infof ("IsLikelyNotMountPoint: %s" , path )
165179 isExists , err := mounter .ExistsPath (path )
166180 if err != nil {
@@ -180,30 +194,30 @@ func (mounter *CSIProxyMounter) IsLikelyNotMountPoint(path string) (bool, error)
180194 return ! response .IsSymlink , nil
181195}
182196
183- func (mounter * CSIProxyMounter ) PathIsDevice (pathname string ) (bool , error ) {
197+ func (mounter * csiProxyMounter ) PathIsDevice (pathname string ) (bool , error ) {
184198 return false , fmt .Errorf ("PathIsDevice not implemented for CSIProxyMounter" )
185199}
186200
187- func (mounter * CSIProxyMounter ) DeviceOpened (pathname string ) (bool , error ) {
201+ func (mounter * csiProxyMounter ) DeviceOpened (pathname string ) (bool , error ) {
188202 return false , fmt .Errorf ("DeviceOpened not implemented for CSIProxyMounter" )
189203}
190204
191- func (mounter * CSIProxyMounter ) GetDeviceNameFromMount (mountPath , pluginMountDir string ) (string , error ) {
205+ func (mounter * csiProxyMounter ) GetDeviceNameFromMount (mountPath , pluginMountDir string ) (string , error ) {
192206 return "" , fmt .Errorf ("GetDeviceNameFromMount not implemented for CSIProxyMounter" )
193207}
194208
195- func (mounter * CSIProxyMounter ) MakeRShared (path string ) error {
209+ func (mounter * csiProxyMounter ) MakeRShared (path string ) error {
196210 return fmt .Errorf ("MakeRShared not implemented for CSIProxyMounter" )
197211}
198212
199- func (mounter * CSIProxyMounter ) MakeFile (pathname string ) error {
213+ func (mounter * csiProxyMounter ) MakeFile (pathname string ) error {
200214 return fmt .Errorf ("MakeFile not implemented for CSIProxyMounter" )
201215}
202216
203217// MakeDir - Creates a directory. The CSI proxy takes in context information.
204218// Currently the make dir is only used from the staging code path, hence we call it
205219// with Plugin context..
206- func (mounter * CSIProxyMounter ) MakeDir (path string ) error {
220+ func (mounter * csiProxyMounter ) MakeDir (path string ) error {
207221 klog .V (4 ).Infof ("Make directory: %s" , path )
208222 mkdirReq := & fs.MkdirRequest {
209223 Path : normalizeWindowsPath (path ),
@@ -217,7 +231,7 @@ func (mounter *CSIProxyMounter) MakeDir(path string) error {
217231}
218232
219233// ExistsPath - Checks if a path exists. Unlike util ExistsPath, this call does not perform follow link.
220- func (mounter * CSIProxyMounter ) ExistsPath (path string ) (bool , error ) {
234+ func (mounter * csiProxyMounter ) ExistsPath (path string ) (bool , error ) {
221235 klog .V (4 ).Infof ("Exists path: %s" , path )
222236 isExistsResponse , err := mounter .FsClient .PathExists (context .Background (),
223237 & fs.PathExistsRequest {
@@ -230,45 +244,45 @@ func (mounter *CSIProxyMounter) ExistsPath(path string) (bool, error) {
230244}
231245
232246// GetAPIVersions returns the versions of the client APIs this mounter is using.
233- func (mounter * CSIProxyMounter ) GetAPIVersions () string {
247+ func (mounter * csiProxyMounter ) GetAPIVersions () string {
234248 return fmt .Sprintf (
235249 "API Versions filesystem: %s, SMB: %s" ,
236250 fsclient .Version ,
237251 smbclient .Version ,
238252 )
239253}
240254
241- func (mounter * CSIProxyMounter ) EvalHostSymlinks (pathname string ) (string , error ) {
255+ func (mounter * csiProxyMounter ) EvalHostSymlinks (pathname string ) (string , error ) {
242256 return "" , fmt .Errorf ("EvalHostSymlinks not implemented for CSIProxyMounter" )
243257}
244258
245- func (mounter * CSIProxyMounter ) GetMountRefs (pathname string ) ([]string , error ) {
259+ func (mounter * csiProxyMounter ) GetMountRefs (pathname string ) ([]string , error ) {
246260 return []string {}, fmt .Errorf ("GetMountRefs not implemented for CSIProxyMounter" )
247261}
248262
249- func (mounter * CSIProxyMounter ) GetFSGroup (pathname string ) (int64 , error ) {
263+ func (mounter * csiProxyMounter ) GetFSGroup (pathname string ) (int64 , error ) {
250264 return - 1 , fmt .Errorf ("GetFSGroup not implemented for CSIProxyMounter" )
251265}
252266
253- func (mounter * CSIProxyMounter ) GetSELinuxSupport (pathname string ) (bool , error ) {
267+ func (mounter * csiProxyMounter ) GetSELinuxSupport (pathname string ) (bool , error ) {
254268 return false , fmt .Errorf ("GetSELinuxSupport not implemented for CSIProxyMounter" )
255269}
256270
257- func (mounter * CSIProxyMounter ) GetMode (pathname string ) (os.FileMode , error ) {
271+ func (mounter * csiProxyMounter ) GetMode (pathname string ) (os.FileMode , error ) {
258272 return 0 , fmt .Errorf ("GetMode not implemented for CSIProxyMounter" )
259273}
260274
261- func (mounter * CSIProxyMounter ) MountSensitive (source string , target string , fstype string , options []string , sensitiveOptions []string ) error {
275+ func (mounter * csiProxyMounter ) MountSensitive (source string , target string , fstype string , options []string , sensitiveOptions []string ) error {
262276 return fmt .Errorf ("MountSensitive not implemented for CSIProxyMounter" )
263277}
264278
265- func (mounter * CSIProxyMounter ) MountSensitiveWithoutSystemd (source string , target string , fstype string , options []string , sensitiveOptions []string ) error {
279+ func (mounter * csiProxyMounter ) MountSensitiveWithoutSystemd (source string , target string , fstype string , options []string , sensitiveOptions []string ) error {
266280 return fmt .Errorf ("MountSensitiveWithoutSystemd not implemented for CSIProxyMounter" )
267281}
268282
269283// NewCSIProxyMounter - creates a new CSI Proxy mounter struct which encompassed all the
270284// clients to the CSI proxy - filesystem, disk and volume clients.
271- func NewCSIProxyMounter () (* CSIProxyMounter , error ) {
285+ func NewCSIProxyMounter () (* csiProxyMounter , error ) {
272286 fsClient , err := fsclient .NewClient ()
273287 if err != nil {
274288 return nil , err
@@ -278,7 +292,7 @@ func NewCSIProxyMounter() (*CSIProxyMounter, error) {
278292 return nil , err
279293 }
280294
281- return & CSIProxyMounter {
295+ return & csiProxyMounter {
282296 FsClient : fsClient ,
283297 SMBClient : smbClient ,
284298 }, nil
0 commit comments