-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
53 lines (44 loc) · 1.19 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
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"kamatera/shell-script-csi-driver/driver"
)
func main() {
var (
endpoint = flag.String("endpoint", "unix:///var/lib/kubelet/plugins/"+driver.DefaultDriverName+"/csi.sock", "CSI endpoint")
driverName = flag.String("driver-name", driver.DefaultDriverName, "Name for the driver")
version = flag.Bool("version", false, "Print the version and exit.")
workdir = flag.String("workdir", "/var/run/kamatera/shell-script-csi-driver", "Workdir for runtime files")
nodeId = flag.String("node-id", "", "The Node ID")
)
flag.Parse()
if *version {
fmt.Printf("%s - %s (%s)\n", driver.GetVersion(), driver.GetCommit(), driver.GetTreeState())
os.Exit(0)
}
if len(*nodeId) < 1 {
fmt.Println("node-id is required")
os.Exit(1)
}
drv, err := driver.NewDriver(*endpoint, *driverName, *workdir, *nodeId)
if err != nil {
log.Fatalln(err)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-c
cancel()
}()
if err := drv.Run(ctx); err != nil {
log.Fatalln(err)
}
}