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

Commit f89b357

Browse files
authored
Merge pull request #26 from vieux/move_1.8
bump to go1.8, use vndr and update vendor
2 parents 6a0fffa + 67cc564 commit f89b357

File tree

235 files changed

+44659
-28968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+44659
-28968
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
matrix:
66
include:
77
- language: go
8-
go: 1.6.x
8+
go: 1.7.x
99
env: TESTFILE=unit.sh
1010
- language: go
11-
go: 1.7.x
11+
go: 1.8.x
1212
env: TESTFILE=unit.sh
1313
- language: go
1414
go: master

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.7-alpine
1+
FROM golang:1.8-alpine
22

33
COPY . /go/src/github.com/vieux/docker-volume-sshfs
44
WORKDIR /go/src/github.com/vieux/docker-volume-sshfs

main.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (d *sshfsDriver) saveState() {
7474
}
7575
}
7676

77-
func (d *sshfsDriver) Create(r volume.Request) volume.Response {
77+
func (d *sshfsDriver) Create(r *volume.CreateRequest) error {
7878
logrus.WithField("method", "create").Debugf("%#v", r)
7979

8080
d.Lock()
@@ -92,131 +92,131 @@ func (d *sshfsDriver) Create(r volume.Request) volume.Response {
9292
case "allow_other":
9393
v.AllowOther = true
9494
default:
95-
return responseError(fmt.Sprintf("unknown option %q=%q", key, val))
95+
return logError("unknown option %q=%q", key, val)
9696
}
9797
}
9898

9999
if v.Sshcmd == "" {
100-
return responseError("'sshcmd' option required")
100+
return logError("'sshcmd' option required")
101101
}
102102
v.Mountpoint = filepath.Join(d.root, fmt.Sprintf("%x", md5.Sum([]byte(v.Sshcmd))))
103103

104104
d.volumes[r.Name] = v
105105

106106
d.saveState()
107107

108-
return volume.Response{}
108+
return nil
109109
}
110110

111-
func (d *sshfsDriver) Remove(r volume.Request) volume.Response {
111+
func (d *sshfsDriver) Remove(r *volume.RemoveRequest) error {
112112
logrus.WithField("method", "remove").Debugf("%#v", r)
113113

114114
d.Lock()
115115
defer d.Unlock()
116116

117117
v, ok := d.volumes[r.Name]
118118
if !ok {
119-
return responseError(fmt.Sprintf("volume %s not found", r.Name))
119+
return logError("volume %s not found", r.Name)
120120
}
121121

122122
if v.connections != 0 {
123-
return responseError(fmt.Sprintf("volume %s is currently used by a container", r.Name))
123+
return logError("volume %s is currently used by a container", r.Name)
124124
}
125125
if err := os.RemoveAll(v.Mountpoint); err != nil {
126-
return responseError(err.Error())
126+
return logError(err.Error())
127127
}
128128
delete(d.volumes, r.Name)
129129
d.saveState()
130-
return volume.Response{}
130+
return nil
131131
}
132132

133-
func (d *sshfsDriver) Path(r volume.Request) volume.Response {
133+
func (d *sshfsDriver) Path(r *volume.PathRequest) (*volume.PathResponse, error) {
134134
logrus.WithField("method", "path").Debugf("%#v", r)
135135

136136
d.RLock()
137137
defer d.RUnlock()
138138

139139
v, ok := d.volumes[r.Name]
140140
if !ok {
141-
return responseError(fmt.Sprintf("volume %s not found", r.Name))
141+
return &volume.PathResponse{}, logError("volume %s not found", r.Name)
142142
}
143143

144-
return volume.Response{Mountpoint: v.Mountpoint}
144+
return &volume.PathResponse{Mountpoint: v.Mountpoint}, nil
145145
}
146146

147-
func (d *sshfsDriver) Mount(r volume.MountRequest) volume.Response {
147+
func (d *sshfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error) {
148148
logrus.WithField("method", "mount").Debugf("%#v", r)
149149

150150
d.Lock()
151151
defer d.Unlock()
152152

153153
v, ok := d.volumes[r.Name]
154154
if !ok {
155-
return responseError(fmt.Sprintf("volume %s not found", r.Name))
155+
return &volume.MountResponse{}, logError("volume %s not found", r.Name)
156156
}
157157

158158
if v.connections == 0 {
159159
fi, err := os.Lstat(v.Mountpoint)
160160
if os.IsNotExist(err) {
161161
if err := os.MkdirAll(v.Mountpoint, 0755); err != nil {
162-
return responseError(err.Error())
162+
return &volume.MountResponse{}, logError(err.Error())
163163
}
164164
} else if err != nil {
165-
return responseError(err.Error())
165+
return &volume.MountResponse{}, logError(err.Error())
166166
}
167167

168168
if fi != nil && !fi.IsDir() {
169-
return responseError(fmt.Sprintf("%v already exist and it's not a directory", v.Mountpoint))
169+
return &volume.MountResponse{}, logError("%v already exist and it's not a directory", v.Mountpoint)
170170
}
171171

172172
if err := d.mountVolume(v); err != nil {
173-
return responseError(err.Error())
173+
return &volume.MountResponse{}, logError(err.Error())
174174
}
175175
}
176176

177177
v.connections++
178178

179-
return volume.Response{Mountpoint: v.Mountpoint}
179+
return &volume.MountResponse{Mountpoint: v.Mountpoint}, nil
180180
}
181181

182-
func (d *sshfsDriver) Unmount(r volume.UnmountRequest) volume.Response {
182+
func (d *sshfsDriver) Unmount(r *volume.UnmountRequest) error {
183183
logrus.WithField("method", "unmount").Debugf("%#v", r)
184184

185185
d.Lock()
186186
defer d.Unlock()
187187
v, ok := d.volumes[r.Name]
188188
if !ok {
189-
return responseError(fmt.Sprintf("volume %s not found", r.Name))
189+
return logError("volume %s not found", r.Name)
190190
}
191191

192192
v.connections--
193193

194194
if v.connections <= 0 {
195195
if err := d.unmountVolume(v.Mountpoint); err != nil {
196-
return responseError(err.Error())
196+
return logError(err.Error())
197197
}
198198
v.connections = 0
199199
}
200200

201-
return volume.Response{}
201+
return nil
202202
}
203203

204-
func (d *sshfsDriver) Get(r volume.Request) volume.Response {
204+
func (d *sshfsDriver) Get(r *volume.GetRequest) (*volume.GetResponse, error) {
205205
logrus.WithField("method", "get").Debugf("%#v", r)
206206

207207
d.Lock()
208208
defer d.Unlock()
209209

210210
v, ok := d.volumes[r.Name]
211211
if !ok {
212-
return responseError(fmt.Sprintf("volume %s not found", r.Name))
212+
return &volume.GetResponse{}, logError("volume %s not found", r.Name)
213213
}
214214

215-
return volume.Response{Volume: &volume.Volume{Name: r.Name, Mountpoint: v.Mountpoint}}
215+
return &volume.GetResponse{Volume: &volume.Volume{Name: r.Name, Mountpoint: v.Mountpoint}}, nil
216216
}
217217

218-
func (d *sshfsDriver) List(r volume.Request) volume.Response {
219-
logrus.WithField("method", "list").Debugf("%#v", r)
218+
func (d *sshfsDriver) List() (*volume.ListResponse, error) {
219+
logrus.WithField("method", "list").Debugf("")
220220

221221
d.Lock()
222222
defer d.Unlock()
@@ -225,13 +225,13 @@ func (d *sshfsDriver) List(r volume.Request) volume.Response {
225225
for name, v := range d.volumes {
226226
vols = append(vols, &volume.Volume{Name: name, Mountpoint: v.Mountpoint})
227227
}
228-
return volume.Response{Volumes: vols}
228+
return &volume.ListResponse{Volumes: vols}, nil
229229
}
230230

231-
func (d *sshfsDriver) Capabilities(r volume.Request) volume.Response {
232-
logrus.WithField("method", "capabilities").Debugf("%#v", r)
231+
func (d *sshfsDriver) Capabilities() *volume.CapabilitiesResponse {
232+
logrus.WithField("method", "capabilities").Debugf("")
233233

234-
return volume.Response{Capabilities: volume.Capability{Scope: "local"}}
234+
return &volume.CapabilitiesResponse{Capabilities: volume.Capability{Scope: "local"}}
235235
}
236236

237237
func (d *sshfsDriver) mountVolume(v *sshfsVolume) error {
@@ -256,9 +256,9 @@ func (d *sshfsDriver) unmountVolume(target string) error {
256256
return exec.Command("sh", "-c", cmd).Run()
257257
}
258258

259-
func responseError(err string) volume.Response {
260-
logrus.Error(err)
261-
return volume.Response{Err: err}
259+
func logError(format string, args ...interface{}) error {
260+
logrus.Errorf(format, args...)
261+
return fmt.Errorf(format, args)
262262
}
263263

264264
func main() {

vendor.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/Sirupsen/logrus 181d419aa9e2223811b824e8f0b4af96f9ba9302
2+
github.com/docker/go-plugins-helpers a9ef19c479cb60e751efa55f7f2b265776af1abf
3+
github.com/Microsoft/go-winio 78439966b38d69bf38227fbf57ac8a6fee70f69a
4+
github.com/coreos/go-systemd d2196463941895ee908e13531a23a39feb9e1243
5+
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
6+
golang.org/x/net 1c05540f6879653db88113bc4a2b70aec4bd491f
7+
golang.org/x/sys 9f7170bcd8e9f4d3691c06401119c46a769a1e03
8+
golang.org/x/crypto b176d7def5d71bdd214203491f89843ed217f420

vendor/github.com/Microsoft/go-winio/backup.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)