-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
217 lines (207 loc) · 4.83 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
package main
import (
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
const (
loglevelDebug = "debug"
loglevelInfo = "info"
logLevelError = "error"
)
func main() {
// Setup logrus
logrus.SetFormatter(&logrus.TextFormatter{})
logrus.SetOutput(os.Stdout)
app := cli.NewApp()
app.Name = "galaxy"
app.Version = "0.1.0"
app.Commands = []cli.Command{
{
Name: "runner",
Usage: "Starts a galaxy runner instance",
Flags: []cli.Flag{
cli.StringFlag{
Name: "port",
EnvVar: "PORT",
Usage: "The port the runner will bind too",
Value: "4050",
},
cli.StringFlag{
Name: "proxy-port",
EnvVar: "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: loglevelInfo,
},
// JWT config
cli.StringFlag{
Name: "jwt-algo",
EnvVar: "JWT_ALGO",
Usage: "The jwt algorithm to use for verification and signing [ hs256 | rsa256 ]",
Value: "hs256",
},
cli.StringFlag{
Name: "jwt-secret",
EnvVar: "JWT_SECRET",
Usage: "The jwt secret to use when the algorithm is set to HS256",
Value: "some-secret",
},
cli.StringFlag{
Name: "jwt-proxy-secret",
EnvVar: "JWT_PROXY_SECRET",
Usage: "The jwt secret to use for authenticating the proxy",
Value: "some-proxy-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.BoolFlag{
Name: "outside-cluster",
EnvVar: "OUTSIDE_CLUSTER",
Usage: "Indicates whether galaxy in running inside the cluster",
},
// Managed service module specific flags
cli.StringSliceFlag{
Name: "providers",
EnvVar: "PROVIDER",
Usage: "key:value pair of the cloud-vendor and technology",
},
// Digital Ocean
cli.StringFlag{
Name: "do-token",
EnvVar: "DO_TOKEN",
Usage: "The token to be used for authentication",
},
cli.StringFlag{
Name: "region",
EnvVar: "REGION",
Usage: "Droplet region",
},
// TODO: add support for other cloud-vendors
},
Action: actionRunner,
},
{
Name: "proxy",
Usage: "Starts the proxy to collect metrics directly from envoy",
Flags: []cli.Flag{
cli.StringFlag{
Name: "addr",
Usage: "Address of the galaxy runner instance",
EnvVar: "ADDR",
Value: "runner.galaxy.svc.cluster.local:4050",
},
cli.StringFlag{
Name: "token",
Usage: "The token to be used for authentication",
EnvVar: "TOKEN",
},
cli.StringFlag{
Name: "log-level",
EnvVar: "LOG_LEVEL",
Usage: "Set the log level [debug | info | error]",
Value: loglevelInfo,
},
},
Action: actionProxy,
},
{
Name: "server",
Usage: "Starts the galaxy server instance",
Flags: []cli.Flag{
cli.StringFlag{
Name: "port",
Usage: "The port the server will bind to",
EnvVar: "PORT",
Value: "4050",
},
cli.StringFlag{
Name: "log-level",
EnvVar: "LOG_LEVEL",
Usage: "Set the log level [debug | info | error]",
Value: loglevelInfo,
},
},
Action: actionServer,
},
{
Name: "code",
Usage: "Commands to work with non dockerized code",
Subcommands: []cli.Command{
{
Name: "start",
Flags: []cli.Flag{
cli.StringFlag{
Name: "env",
Usage: "Builds and deploys a codebase",
EnvVar: "ENV",
Value: "none",
},
},
Action: actionStartCode,
},
{
Name: "build",
Flags: []cli.Flag{
cli.StringFlag{
Name: "env",
Usage: "Builds a codebase",
EnvVar: "ENV",
Value: "none",
},
},
Action: actionBuildCode,
},
},
},
{
Name: "login",
Usage: "Commands to log in",
Flags: []cli.Flag{
cli.StringFlag{
Name: "username",
Usage: "Accepts the username for login",
EnvVar: "USERNAME",
Value: "None",
},
cli.StringFlag{
Name: "key",
Usage: "Accepts the access key to be verified during login",
EnvVar: "KEY",
Value: "None",
},
cli.StringFlag{
Name: "url",
Usage: "Accepts the URL of server",
EnvVar: "URL",
Value: "noorain.bolega.com",
},
cli.BoolFlag{
Name: "local",
Usage: "Determines whether local URL is to be used as server URL",
EnvVar: "LOCAL",
},
},
Action: actionLogin,
},
}
// Start the app
if err := app.Run(os.Args); err != nil {
logrus.Fatalln("Failed to start galaxy:", err)
}
}