/
main.go
55 lines (40 loc) · 1.2 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"flag"
"fmt"
"github.com/docker/go-plugins-helpers/volume"
"path/filepath"
)
const pluginName = "ebs"
var root = flag.String("root", volume.DefaultDockerRootDirectory, "Docker volumes root directory")
type ebsDriver struct {
root string
}
func (e ebsDriver) Create(r volume.Request) volume.Response {
fmt.Printf("Create %v\n", r)
return volume.Response{}
}
func (e ebsDriver) Remove(r volume.Request) volume.Response {
fmt.Printf("Remove %v\n", r)
return volume.Response{}
}
func (e ebsDriver) Path(r volume.Request) volume.Response {
fmt.Printf("Path %v\n", r)
return volume.Response{Mountpoint: filepath.Join(e.root, r.Name)}
}
func (e ebsDriver) Mount(r volume.Request) volume.Response {
p := filepath.Join(e.root, r.Name)
fmt.Printf("Mount %s\n", p)
return volume.Response{Mountpoint: p}
}
func (e ebsDriver) Unmount(r volume.Request) volume.Response {
p := filepath.Join(e.root, r.Name)
fmt.Printf("Unmount %s\n", p)
return volume.Response{}
}
func main() {
d := ebsDriver{*root}
h := volume.NewHandler(d)
fmt.Printf("Starting listening on unix socket with name %s (usually in /run/docker/plugins/%s)\n", pluginName, pluginName)
h.ServeUnix("root", pluginName)
}