forked from gen0cide/laforge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.go
313 lines (308 loc) · 7.64 KB
/
commands.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/gen0cide/laforge/command"
)
var GlobalFlags = []cli.Flag{}
var Commands = []cli.Command{
{
Name: "init",
Usage: "Configure your current LaForge environment.",
Action: command.CmdInit,
Flags: []cli.Flag{},
},
{
Name: "cdn",
Usage: "Manipulate files in the CDN.",
Action: command.CmdCDN,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List files in the CDN.",
Action: command.CmdCDNLs,
},
{
Name: "link",
Usage: "Get the public URL for a file in the CDN.",
Action: command.CmdCDNLink,
},
{
Name: "upload",
Usage: "Upload a file to the CDN.",
Action: command.CmdCDNUpload,
},
{
Name: "rm",
Usage: "Delete a file from the CDN.",
Action: command.CmdCDNRm,
},
},
},
{
Name: "doctor",
Usage: "Check to see if you have the required dependencies to use LaForge.",
Action: command.CmdDoctor,
Flags: []cli.Flag{},
},
{
Name: "network",
Usage: "Manage Networks within your current LaForge environment.",
Action: command.CmdNetwork,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List the current environment's networks.",
Action: command.CmdNetworkLs,
},
{
Name: "create",
Usage: "Create a new network.",
Action: command.CmdNetworkCreate,
},
},
},
{
Name: "host",
Usage: "Manage Hosts within your networks.",
Action: command.CmdHost,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List the current environment's hosts.",
Action: command.CmdHostLs,
},
{
Name: "create",
Usage: "Create a new host.",
Action: command.CmdHostCreate,
},
},
},
{
Name: "env",
Usage: "Manage LaForge competition environment.",
Action: command.CmdEnv,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List the current competition environments located in the LF_HOME path.",
Action: command.CmdEnvLs,
},
{
Name: "use",
Usage: "Switch the current LaForge context to the specified competition environment.",
Action: command.CmdEnvUse,
},
{
Name: "create",
Usage: "List the current competition environments located in the LF_HOME path.",
Action: command.CmdEnvCreate,
},
{
Name: "bashconfig",
Usage: "Generate a bash env config for some productive aliases.",
Action: command.CmdEnvBashConfig,
},
{
Name: "team-password",
Usage: "Deterministically generate the password for a given Pod ID.",
Action: command.CmdEnvPassword,
},
{
Name: "sshconfig",
Usage: "Write an SSH configuration to TF_HOME/environments/TF_ENV/ssh.conf",
Action: command.CmdEnvSshConfig,
},
},
},
{
Name: "build",
Usage: "Build the current competition environment into a terraform configuration.",
Action: command.CmdBuild,
Flags: []cli.Flag{},
},
{
Name: "tf",
Usage: "Perform terraform functions on the current competition environment.",
Action: command.CmdTf,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "init",
Usage: "Initialize the terraform directory.",
Action: command.CmdTfInit,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
{
Name: "plan",
Usage: "Plan the terraform changes with the state delta.",
Action: command.CmdTfPlan,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
{
Name: "apply",
Usage: "Apply the current terraform plan.",
Action: command.CmdTfApply,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
{
Name: "output",
Usage: "Show the terraform outputs.",
Action: command.CmdTfOutput,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
},
},
{
Name: "refresh",
Usage: "Refresh the terraform state.",
Action: command.CmdTfRefresh,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
{
Name: "taint",
Usage: "Taint an object in the dependency graph.",
Action: command.CmdTfTaint,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
},
},
{
Name: "state",
Usage: "Show the current dependency tree.",
Action: command.CmdTfState,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
{
Name: "destroy",
Usage: "Destroy the current environment.",
Action: command.CmdTfDestroy,
Flags: []cli.Flag{
cli.IntFlag{
Name: "team, t",
Value: 0,
Usage: "The team you wish to perform the terraform actions on. (Default = 0)",
},
cli.IntFlag{
Name: "parallelism, p",
Value: 10,
Usage: "The number of parallel workers you want terraform to use. (Default = 10)",
},
},
},
},
},
{
Name: "ssh",
Usage: "Allows for administrative SSH access to hosts in the current competition environment.",
Action: command.CmdSsh,
Flags: []cli.Flag{},
},
{
Name: "powershell",
Usage: "Creates an interactive powershell session for a host in the current competition environment.",
Action: command.CmdPowershell,
Flags: []cli.Flag{},
},
{
Name: "app",
Usage: "Custom application package management within the current environment.",
Action: command.CmdApp,
Flags: []cli.Flag{},
Subcommands: []cli.Command{
{
Name: "ls",
Usage: "List this competition's current applications.",
Action: command.CmdAppLs,
},
{
Name: "create",
Usage: "Create a new skeleton application.",
Action: command.CmdAppCreate,
},
{
Name: "pkg",
Usage: "Package and upload the current application to S3.",
Action: command.CmdAppPkg,
},
},
},
{
Name: "update",
Usage: "Updates laforge to your the latest release.",
Action: command.CmdUpdate,
},
}
func CommandNotFound(c *cli.Context, command string) {
fmt.Fprintf(os.Stderr, "%s: '%s' is not a %s command. See '%s --help'.", c.App.Name, command, c.App.Name, c.App.Name)
os.Exit(2)
}