forked from calavera/docker-volume-glusterfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (32 loc) · 956 Bytes
/
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
package main
import (
"flag"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/docker/go-plugins-helpers/volume"
)
const glusterfsID = "_glusterfs"
var (
defaultDir = filepath.Join(volume.DefaultDockerRootDirectory, glusterfsID)
serversList = flag.String("servers", "", "List of glusterfs servers")
restAddress = flag.String("rest", "", "URL to glusterfsrest api")
gfsBase = flag.String("gfs-base", "/mnt/gfs", "Base directory where volumes are created in the cluster")
root = flag.String("root", defaultDir, "GlusterFS volumes root directory")
)
func main() {
var Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
if len(*serversList) == 0 {
Usage()
os.Exit(1)
}
servers := strings.Split(*serversList, ":")
d := newGlusterfsDriver(*root, *restAddress, *gfsBase, servers)
h := volume.NewHandler(d)
fmt.Println(h.ServeUnix("root", "glusterfs"))
}