-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmain.go
69 lines (61 loc) · 1.28 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
69
package main
import (
"context"
"fmt"
"os"
"github.com/rancher/k3v/pkg/server"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
Version = "v0.0.0-dev"
GitCommit = "HEAD"
config server.Config
)
func main() {
app := cli.NewApp()
app.Name = "k3v"
app.Version = fmt.Sprintf("%s (%s)", Version, GitCommit)
app.Usage = "Virtual Kubernetes"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "kubeconfig",
EnvVar: "KUBECONFIG",
Destination: &config.KubeConfig,
},
cli.StringFlag{
Name: "id",
EnvVar: "K3V_ID",
Value: "1",
Destination: &config.ID,
},
cli.StringFlag{
Name: "namespace",
EnvVar: "NAMESPACE",
Value: "default",
Destination: &config.Namespace,
},
cli.IntFlag{
Name: "listen-port",
EnvVar: "K3V_LISTEN_PORT",
Value: 7443,
Destination: &config.ListenPort,
},
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)
}
logrus.Info("Starting controller")
ctx := signals.SetupSignalHandler(context.Background())
return server.Run(ctx, config)
}