@@ -11,46 +11,52 @@ import (
1111)
1212
1313// Components, in the order in which they must be started.
14+ //
15+ // This list describes all of the components that the CLI has the ability to
16+ // manage. When things are installed, namespaces, services, volumes and secrets
17+ // are installed first, then pods and rcs are installed.
1418var components = []* platform.Component {
1519 {
1620 Name : "builder" ,
1721 Description : "the builder" ,
18- RCs : []string {"deis-builder.json" },
19- Services : []string {"deis-builder-service.json" },
22+ Namespaces : []string {"namespaces/deis-namespace.json" },
23+ RCs : []string {"rcs/deis-builder.json" },
24+ Services : []string {"services/deis-builder-service.json" },
2025 },
2126 {
2227 Name : "controller" ,
2328 Description : "the controller" ,
24- RCs : []string {"deis-controller.json" },
25- Services : []string {"deis-controller-service.json" },
29+ RCs : []string {"rcs/ deis-controller.json" },
30+ Services : []string {"services/ deis-controller-service.json" },
2631 },
2732 {
2833 Name : "database" ,
2934 Description : "the database" ,
30- RCs : []string {"deis-database.json" },
31- Services : []string {"deis-database-service.json" },
35+ RCs : []string {"rcs/ deis-database.json" },
36+ Services : []string {"services/ deis-database-service.json" },
3237 },
3338 {
3439 Name : "registry" ,
3540 Description : "the registry" ,
36- RCs : []string {"deis-registry.json" },
37- Services : []string {"deis-registry-service.json" },
41+ RCs : []string {"rcs/ deis-registry.json" },
42+ Services : []string {"services/ deis-registry-service.json" },
3843 },
3944 {
4045 Name : "router" ,
4146 Description : "the router mesh" ,
42- RCs : []string {"router.json" },
43- Services : []string {"router-service.json" },
47+ RCs : []string {"rcs/deis- router.json" },
48+ // Services: []string{"services/deis- router-service.json"},
4449 },
4550 {
4651 Name : "store" ,
4752 Description : "the persistent storage cluster" ,
48- RCs : []string {"deis-store-gtw.json" , "deis-store-mds.json" , "deis-store-mon.json" , "deis-store-osd.json" },
49- Services : []string {"deis-store-gtw-service.json" },
53+ RCs : []string {"rcs/ deis-store-gtw.json" , "rcs/ deis-store-mds.json" , "rcs/ deis-store-mon.json" , "rcs/ deis-store-osd.json" },
54+ Services : []string {"services/ deis-store-gtw-service.json" },
5055 Optional : true ,
5156 },
5257}
5358
59+ // config is where configuration data is stored.
5460var config storage.Storer
5561
5662func main () {
@@ -68,21 +74,35 @@ func main() {
6874 app := cli .NewApp ()
6975 app .Name = "trireme"
7076 app .Usage = "A control tool for Deis"
77+ app .Flags = []cli.Flag {
78+ // This is currently not used.
79+ cli.StringFlag {
80+ Name : "tunnel, t" ,
81+ Value : "127.0.0.1" ,
82+ EnvVar : "DEISCTL_TUNNEL" ,
83+ Usage : "The IP address or hostname of the tunnel." ,
84+ },
85+ }
7186 app .Commands = commands ()
7287 app .Run (os .Args )
7388}
7489
7590func commands () []cli.Command {
7691 return []cli.Command {
92+ {
93+ Name : "config" ,
94+ Usage : "Get and set configuration values" ,
95+ Subcommands : configCommands (),
96+ },
7797 {
7898 Name : "install" ,
7999 Usage : "Install platform components" ,
80100 Subcommands : installCommands (),
81101 },
82102 {
83- Name : "config " ,
84- Usage : "Get and set configuration values " ,
85- Subcommands : configCommands (),
103+ Name : "uninstall " ,
104+ Usage : "Uninstall platform components " ,
105+ Subcommands : uninstallCommands (),
86106 },
87107 }
88108}
@@ -200,7 +220,6 @@ func configCommands() []cli.Command {
200220}
201221
202222func installCommands () []cli.Command {
203-
204223 // This basically ensures that append() will not have to reallocate.
205224 cmds := make ([]cli.Command , 0 , len (components )+ 1 )
206225
@@ -219,10 +238,10 @@ func installCommands() []cli.Command {
219238 Action : installPlatform ,
220239 Flags : []cli.Flag {
221240 cli.StringFlag {
222- Name : "units , u" ,
223- Value : "units/" ,
241+ Name : "unit-files , u" ,
242+ Value : "./ units/" ,
224243 Usage : "The path to the Deis Kubernetes JSON unit files." ,
225- EnvVar : "DEIS_K8S_UNITS " ,
244+ EnvVar : "DEISCTL_UNITS " ,
226245 },
227246 cli.StringFlag {
228247 Name : "registry, r" ,
@@ -231,29 +250,89 @@ func installCommands() []cli.Command {
231250 },
232251 },
233252 })
253+ return cmds
254+ }
255+ func uninstallCommands () []cli.Command {
256+ // This basically ensures that append() will not have to reallocate.
257+ cmds := make ([]cli.Command , 0 , len (components )+ 1 )
234258
259+ for _ , c := range components {
260+ n := c .Name
261+ v := c .Description
262+ cmds = append (cmds , cli.Command {
263+ Name : n ,
264+ Usage : fmt .Sprintf ("Uninstall %s." , v ),
265+ Action : func (c * cli.Context ) { uninstallComponent (c , n ) },
266+ })
267+ }
268+ cmds = append (cmds , cli.Command {
269+ Name : "platform" ,
270+ Usage : "Uninstall the entire platform" ,
271+ Action : uninstallPlatform ,
272+ Flags : []cli.Flag {
273+ cli.StringFlag {
274+ Name : "unit-files, u" ,
275+ Value : "./units/" ,
276+ Usage : "The path to the Deis Kubernetes JSON unit files." ,
277+ EnvVar : "DEISCTL_UNITS" ,
278+ },
279+ cli.StringFlag {
280+ Name : "registry, r" ,
281+ Usage : "The URL to a Docker registry that holds Deis images images." ,
282+ EnvVar : "DEV_REGISTRY" ,
283+ },
284+ },
285+ })
235286 return cmds
236287}
237288
238289func installPlatform (c * cli.Context ) {
239290 fmt .Println ("Installing platform" )
240- if err := platform .InstallAll (components , false ); err != nil {
291+
292+ dir := c .String ("unit-files" )
293+ if err := platform .InstallAll (components , dir , false ); err != nil {
241294 fmt .Printf ("Failed to install platform: %s\n " , err )
242295 os .Exit (500 )
243296 }
244297}
298+
299+ func uninstallPlatform (c * cli.Context ) {
300+ dir := c .String ("unit-files" )
301+ if err := platform .DeleteAll (components , dir ); err != nil {
302+ fmt .Printf ("Failed to uninstall platform: %s\n " , err )
303+ os .Exit (500 )
304+ }
305+ }
245306func installComponent (c * cli.Context , name string ) {
246307 comp , err := findComponent (name )
247308 if err != nil {
248309 fmt .Printf ("Failed to install %s: %s\n " , name , err )
249310 os .Exit (404 )
250311 }
251- if err := comp .InstallPrereqs (); err != nil {
252- fmt .Printf ("Failed to install prereqs of %s: %s\n " , name , err )
312+ dir := c .String ("unit-files" )
313+ if err := comp .Install (dir ); err != nil {
314+ fmt .Printf ("Failed to install %s: %s\n " , name , err )
253315 os .Exit (500 )
254316 }
255- if err := comp .Install (); err != nil {
256- fmt .Printf ("Failed to install %s: %s\n " , name , err )
317+ if err := comp .InstallPrereqs (dir ); err != nil {
318+ fmt .Printf ("Failed to install dependencies of %s: %s\n " , name , err )
319+ os .Exit (500 )
320+ }
321+ }
322+
323+ func uninstallComponent (c * cli.Context , name string ) {
324+ comp , err := findComponent (name )
325+ if err != nil {
326+ fmt .Printf ("Failed to uninstall %s: %s\n " , name , err )
327+ os .Exit (404 )
328+ }
329+ dir := c .String ("unit-files" )
330+ if err := comp .Delete (dir ); err != nil {
331+ fmt .Printf ("Failed to uninstall %s: %s\n " , name , err )
332+ os .Exit (500 )
333+ }
334+ if err := comp .DeletePrereqs (dir ); err != nil {
335+ fmt .Printf ("Failed to uninstall dependencies of %s: %s\n " , name , err )
257336 os .Exit (500 )
258337 }
259338}
0 commit comments