Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit 1913825

Browse files
authored
Merge pull request #29 from vieux/support_all_o
passthrough any -o
2 parents f89b357 + ac7d321 commit 1913825

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

.travis/integration.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,31 @@ docker pull rastasheep/ubuntu-sshd:14.04
88
docker pull busybox
99

1010
#script
11+
12+
# make the plugin
1113
make
14+
# enable the plugin
1215
make enable
16+
# list plugins
1317
docker plugin ls
18+
# start sshd
1419
docker run -d -p 2222:22 rastasheep/ubuntu-sshd:14.04
20+
21+
# test1: simple
1522
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o port=2222 -o password=root sshvolume
16-
docker volume ls
17-
docker run -it -v sshvolume:/data1 busybox sh -c "echo hello > /data1/world"
18-
docker run -it -v sshvolume:/data2 busybox grep -Fxq hello /data2/world
23+
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
24+
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
25+
docker volume rm sshvolume
26+
27+
# test2: allow_other
28+
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o allow_other -o port=2222 -o password=root sshvolume
29+
docker run --rm -v sshvolume:/write -u nobody busybox sh -c "echo hello > /write/world"
30+
docker run --rm -v sshvolume:/read -u nobody busybox grep -Fxq hello /read/world
31+
docker volume rm sshvolume
32+
33+
# test3: compression
34+
docker volume create -d vieux/sshfs:next -o sshcmd=root@localhost:/ -o Ciphers=arcfour -o Compression=no -o port=2222 -o password=root sshvolume
35+
docker run --rm -v sshvolume:/write busybox sh -c "echo hello > /write/world"
36+
docker run --rm -v sshvolume:/read busybox grep -Fxq hello /read/world
37+
docker volume rm sshvolume
38+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ docker plugin install vieux/sshfs # or docker plugin install vieux/sshfs DEBUG
1616
2 - Create a volume
1717

1818
```
19-
$ docker volume create -d vieux/sshfs -o sshcmd=<user@host:path> -o password=<password> [-o port=<port>] [-o allow_other] sshvolume
19+
$ docker volume create -d vieux/sshfs -o sshcmd=<user@host:path> -o password=<password> [-o port=<port>] [-o <any_sshfs_-o_option> ] sshvolume
2020
sshvolume
2121
$ docker volume ls
2222
DRIVER VOLUME NAME

main.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import (
2020
const socketAddress = "/run/docker/plugins/sshfs.sock"
2121

2222
type sshfsVolume struct {
23-
Password string
24-
Sshcmd string
25-
Port string
26-
AllowOther bool
23+
Password string
24+
Sshcmd string
25+
Port string
26+
27+
Options []string
2728

2829
Mountpoint string
2930
connections int
@@ -89,10 +90,12 @@ func (d *sshfsDriver) Create(r *volume.CreateRequest) error {
8990
v.Password = val
9091
case "port":
9192
v.Port = val
92-
case "allow_other":
93-
v.AllowOther = true
9493
default:
95-
return logError("unknown option %q=%q", key, val)
94+
if val != "" {
95+
v.Options = append(v.Options, key+"="+val)
96+
} else {
97+
v.Options = append(v.Options, key)
98+
}
9699
}
97100
}
98101

@@ -243,9 +246,11 @@ func (d *sshfsDriver) mountVolume(v *sshfsVolume) error {
243246
cmd.Args = append(cmd.Args, "-o", "workaround=rename", "-o", "password_stdin")
244247
cmd.Stdin = strings.NewReader(v.Password)
245248
}
246-
if v.AllowOther {
247-
cmd.Args = append(cmd.Args, "-o", "allow_other")
249+
250+
for _, option := range v.Options {
251+
cmd.Args = append(cmd.Args, "-o", option)
248252
}
253+
249254
logrus.Debug(cmd.Args)
250255
return cmd.Run()
251256
}

0 commit comments

Comments
 (0)