This repository was archived by the owner on Oct 19, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ $ docker plugin install vieux/sshfs # or docker plugin install vieux/sshfs DEBUG
15152 - Create a volume
1616
1717```
18- $ docker volume create -d vieux/sshfs -o sshcmd=<user@host:path> -o password=<password> sshvolume
18+ $ docker volume create -d vieux/sshfs -o sshcmd=<user@host:path> -o password=<password> [-o port=<port>] sshvolume
1919sshvolume
2020$ docker volume ls
2121DRIVER VOLUME NAME
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const socketAddress = "/run/docker/plugins/sshfs.sock"
2121type sshfsVolume struct {
2222 Password string
2323 Sshcmd string
24+ Port string
2425
2526 Mountpoint string
2627 connections int
@@ -77,11 +78,23 @@ func (d *sshfsDriver) Create(r volume.Request) volume.Response {
7778 d .Lock ()
7879 defer d .Unlock ()
7980 v := & sshfsVolume {}
80- if r .Options == nil || r .Options ["sshcmd" ] == "" {
81- return responseError ("ssh option required" )
81+
82+ for key , val := range r .Options {
83+ switch key {
84+ case "sshcmd" :
85+ v .Sshcmd = val
86+ case "password" :
87+ v .Password = val
88+ case "port" :
89+ v .Port = val
90+ default :
91+ return responseError (fmt .Sprintf ("unknown option %q" , val ))
92+ }
93+ }
94+
95+ if v .Sshcmd == "" {
96+ return responseError ("'sshcmd' option required" )
8297 }
83- v .Sshcmd = r .Options ["sshcmd" ]
84- v .Password = r .Options ["password" ]
8598 v .Mountpoint = filepath .Join (d .root , fmt .Sprintf ("%x" , md5 .Sum ([]byte (v .Sshcmd ))))
8699
87100 d .volumes [r .Name ] = v
@@ -219,6 +232,9 @@ func (d *sshfsDriver) Capabilities(r volume.Request) volume.Response {
219232
220233func (d * sshfsDriver ) mountVolume (v * sshfsVolume ) error {
221234 cmd := fmt .Sprintf ("sshfs -oStrictHostKeyChecking=no %s %s" , v .Sshcmd , v .Mountpoint )
235+ if v .Port != "" {
236+ cmd = fmt .Sprintf ("%s -p %s" , cmd , v .Port )
237+ }
222238 if v .Password != "" {
223239 cmd = fmt .Sprintf ("echo %s | %s -o workaround=rename -o password_stdin" , v .Password , cmd )
224240 }
You can’t perform that action at this time.
0 commit comments