@@ -10,7 +10,7 @@ import (
1010)
1111
1212const (
13- NfsOptions = "nfsopts"
13+ NfsOptions = "nfsopts"
1414 DefaultNfsV3 = "port=2049,nolock,proto=tcp"
1515)
1616
@@ -19,14 +19,13 @@ type nfsDriver struct {
1919 version int
2020 mountm * mountManager
2121 m * sync.Mutex
22- opts map [string ]string
22+ opts map [string ]string
2323}
2424
2525var (
2626 EmptyMap = map [string ]string {}
2727)
2828
29-
3029func NewNFSDriver (root string , version int , options string ) nfsDriver {
3130 d := nfsDriver {
3231 root : root ,
@@ -63,12 +62,12 @@ func (n nfsDriver) Path(r volume.Request) volume.Response {
6362
6463func (s nfsDriver ) Get (r volume.Request ) volume.Response {
6564 log .Debugf ("Get for %s is at %s" , r .Name , mountpoint (s .root , r .Name ))
66- return volume.Response { Volume : & volume.Volume {Name : r .Name , Mountpoint : mountpoint (s .root , r .Name )}}
65+ return volume.Response {Volume : & volume.Volume {Name : r .Name , Mountpoint : mountpoint (s .root , r .Name )}}
6766}
6867
6968func (s nfsDriver ) List (r volume.Request ) volume.Response {
7069 log .Debugf ("List Volumes" )
71- return volume.Response { Volumes : s .mountm .GetVolumes (s .root ) }
70+ return volume.Response {Volumes : s .mountm .GetVolumes (s .root )}
7271}
7372
7473func (n nfsDriver ) Mount (r volume.Request ) volume.Response {
@@ -140,31 +139,38 @@ func (n nfsDriver) mountVolume(source, dest string, version int) error {
140139 if val , ok := options [NfsOptions ]; ok {
141140 opts = val
142141 }
142+
143+ mountCmd := "mount"
144+
145+ if log .GetLevel () == log .DebugLevel {
146+ mountCmd = mountCmd + " -v"
147+ }
148+
143149 switch version {
144150 case 3 :
145151 log .Debugf ("Mounting with NFSv3 - src: %s, dest: %s" , source , dest )
146152 if len (opts ) < 1 {
147153 opts = DefaultNfsV3
148154 }
149- cmd = fmt .Sprintf ("mount -o %s %s %s" , opts , source , dest )
155+ cmd = fmt .Sprintf ("%s -o %s %s %s" , mountCmd , opts , source , dest )
150156 default :
151157 log .Debugf ("Mounting with NFSv4 - src: %s, dest: %s" , source , dest )
152158 if len (opts ) > 0 {
153- cmd = fmt .Sprintf ("mount -t nfs4 -o %s %s %s" , opts , source , dest )
159+ cmd = fmt .Sprintf ("%s -t nfs4 -o %s %s %s" , mountCmd , opts , source , dest )
154160 } else {
155- cmd = fmt .Sprintf ("mount -t nfs4 %s %s" , source , dest )
161+ cmd = fmt .Sprintf ("%s -t nfs4 %s %s" , mountCmd , source , dest )
156162 }
157163 }
158164 log .Debugf ("exec: %s\n " , cmd )
159165 return run (cmd )
160166}
161167
162168func (n nfsDriver ) mountOptions (src map [string ]string ) map [string ]string {
163- if ( len (n .opts ) == 0 && len (src ) == 0 ) {
169+ if len (n .opts ) == 0 && len (src ) == 0 {
164170 return EmptyMap
165171 }
166172
167- dst := map [string ]string {}
173+ dst := map [string ]string {}
168174 for k , v := range n .opts {
169175 dst [k ] = v
170176 }
0 commit comments