-
Notifications
You must be signed in to change notification settings - Fork 214
/
main.go
125 lines (117 loc) · 2.98 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
"context"
"fmt"
"os"
"github.com/spaceuptech/helpers"
"github.com/urfave/cli"
"github.com/spaceuptech/space-cloud/runner/model"
"github.com/spaceuptech/space-cloud/runner/modules/routing"
"github.com/spaceuptech/space-cloud/runner/modules/secrets"
)
func main() {
app := cli.NewApp()
app.Name = "runner"
app.Version = model.Version
app.Commands = []cli.Command{
{
Name: "generate",
Usage: "generates service config",
Subcommands: []cli.Command{
{
Name: "service-routing",
Action: routing.ActionGenerateServiceRouting,
},
{
Name: "apply-secrets",
Action: secrets.ActionGenerateSecret,
},
},
},
{
Name: "start",
Usage: "Starts a runner instance",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "disable-metrics",
EnvVar: "DISABLE_METRICS",
Usage: "Delete anonymous metric collection",
},
cli.BoolFlag{
Name: "dev",
EnvVar: "DEV",
Usage: "start runner without authentication",
},
cli.StringFlag{
Name: "cluster-id",
EnvVar: "CLUSTER_ID",
Usage: "The cluster id to uniquely identify the cluster",
Value: "first-cluster",
},
cli.StringFlag{
Name: "cluster-name",
EnvVar: "CLUSTER_NAME",
Usage: "The cluster name to uniquely identify the docker clusters",
Value: "default",
},
cli.StringFlag{
Name: "port",
Usage: "The port the runner will bind too",
Value: "4050",
},
cli.StringFlag{
Name: "proxy-port",
Usage: "The port the proxy will bind too",
Value: "4055",
},
cli.StringFlag{
Name: "log-level",
EnvVar: "LOG_LEVEL",
Usage: "Set the log level [debug | info | error]",
Value: helpers.LogLevelInfo,
},
cli.StringFlag{
Name: "log-format",
EnvVar: "LOG_FORMAT",
Usage: "Set the log format [json | console]",
Value: helpers.LogFormatJSON,
},
// JWT config
cli.StringFlag{
Name: "jwt-secret",
EnvVar: "JWT_SECRET",
Usage: "The jwt secret to use when the algorithm is set to HS256",
Value: "some-secret",
},
// Driver config
cli.StringFlag{
Name: "driver",
EnvVar: "DRIVER",
Usage: "The driver to use for deployment",
Value: "istio",
},
cli.StringFlag{
Name: "driver-config",
EnvVar: "DRIVER_CONFIG",
Usage: "Driver config file path",
},
cli.StringFlag{
Name: "prometheus-addr",
EnvVar: "PROMETHEUS_ADDR",
Usage: "The address used to reach prometheus",
Value: "http://prometheus.space-cloud.svc.cluster.local:9090",
},
cli.BoolFlag{
Name: "outside-cluster",
EnvVar: "OUTSIDE_CLUSTER",
Usage: "Indicates whether runner in running inside the cluster",
},
},
Action: actionRunner,
},
}
// Start the app
if err := app.Run(os.Args); err != nil {
helpers.Logger.LogFatal(helpers.GetRequestID(context.TODO()), fmt.Sprintf("Failed to start runner: %v", err), nil)
}
}