forked from harvester/harvester-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (57 loc) · 1.41 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
56
57
58
59
60
61
62
63
64
65
66
package main
import (
_ "net/http/pprof"
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/harvester/harvester-csi-driver/pkg/config"
"github.com/harvester/harvester-csi-driver/pkg/csi"
"github.com/harvester/harvester-csi-driver/pkg/version"
)
var (
cfg config.Config
)
func main() {
flags := []cli.Flag{
cli.StringFlag{
Name: "endpoint",
Value: "unix:///csi/csi.sock",
Usage: "CSI endpoint",
Destination: &cfg.Endpoint,
},
cli.StringFlag{
Name: "nodeid",
Usage: "Node ID",
Destination: &cfg.NodeID,
},
cli.StringFlag{
Name: "kubeconfig",
Value: "",
Usage: "kubeconfig to access host Harvester cluster",
Destination: &cfg.KubeConfig,
},
cli.StringFlag{
Name: "host-storage-class",
Value: "",
EnvVar: "HOST_STORAGE_CLASS",
Usage: "storage class of volumes created in the host cluster",
Destination: &cfg.HostStorageClass,
},
}
app := cli.NewApp()
app.Name = "harvester CSI driver"
app.Version = version.FriendlyVersion()
app.Flags = flags
app.Action = func(c *cli.Context) {
if err := runCSI(c); err != nil {
logrus.Fatalf("Error running CSI driver: %v", err)
}
}
if err := app.Run(os.Args); err != nil {
logrus.Fatalf("Error running CSI driver: %v", err)
}
}
func runCSI(*cli.Context) error {
manager := csi.GetCSIManager()
return manager.Run(&cfg)
}