forked from k3s-io/kine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (62 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
67
68
package main
import (
"context"
"os"
"github.com/oneinfra/kine/pkg/endpoint"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
config endpoint.Config
)
func main() {
app := cli.NewApp()
app.Name = "kine"
app.Description = "Minimal etcd v3 API to support custom Kubernetes storage engines"
app.Usage = "Mini"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "listen-address",
Value: "tcp://0.0.0.0:2379",
Destination: &config.Listener,
},
cli.StringFlag{
Name: "endpoint",
Usage: "Storage endpoint (default is sqlite)",
Destination: &config.Endpoint,
},
cli.StringFlag{
Name: "ca-file",
Usage: "CA cert for DB connection",
Destination: &config.CAFile,
},
cli.StringFlag{
Name: "cert-file",
Usage: "Certificate for DB connection",
Destination: &config.CertFile,
},
cli.StringFlag{
Name: "key-file",
Usage: "Key file for DB connection",
Destination: &config.KeyFile,
},
cli.BoolFlag{Name: "debug"},
}
app.Action = run
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}
func run(c *cli.Context) error {
if c.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
ctx := signals.SetupSignalHandler(context.Background())
_, err := endpoint.Listen(ctx, config)
if err != nil {
return err
}
<-ctx.Done()
return ctx.Err()
}