From 623579ecf75b162fcdfad08c7b9a15803363c87a Mon Sep 17 00:00:00 2001 From: deniseschannon Date: Wed, 17 Aug 2016 10:46:22 -0700 Subject: [PATCH] Random fixes --- cmd/config.go | 2 +- cmd/restart.go | 21 ++++++++++++++++++--- cmd/rm.go | 11 ++++++++--- cmd/start.go | 9 +++++++-- cmd/stop.go | 11 ++++++++--- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 709b10666be..8f115c1cf60 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -125,7 +125,7 @@ func configSetup(ctx *cli.Context) error { return err } - if ctx.Bool("dump") { + if ctx.Bool("print") { return json.NewEncoder(os.Stdout).Encode(config) } diff --git a/cmd/restart.go b/cmd/restart.go index b02efacc52c..7caf42238e8 100644 --- a/cmd/restart.go +++ b/cmd/restart.go @@ -45,14 +45,24 @@ func restartResources(ctx *cli.Context) error { return err } + w, err := NewWaiter(ctx) + if err != nil { + return err + } + types := ctx.StringSlice("type") var lastErr error + var envErr error for _, id := range ctx.Args() { resource, err := Lookup(c, id, types...) if err != nil { lastErr = err - fmt.Println(lastErr) + if _, envErr = LookupEnvironment(c, id); envErr != nil { + fmt.Println("Incorrect usage: Environments cannot be restarted.") + } else { + fmt.Println(lastErr) + } continue } @@ -65,9 +75,14 @@ func restartResources(ctx *cli.Context) error { lastErr = err fmt.Println(lastErr) } else { - fmt.Println(resource.Id) + w.Add(resource.Id) + //fmt.Println(resource.Id) + } + + if lastErr != nil && envErr == nil { + return lastErr } } - return lastErr + return w.Wait() } diff --git a/cmd/rm.go b/cmd/rm.go index fd688bca8de..827d879ebad 100644 --- a/cmd/rm.go +++ b/cmd/rm.go @@ -7,7 +7,7 @@ import ( ) var ( - rmTypes = []string{"service", "container", "host", "environment", "machine"} + rmTypes = []string{"service", "container", "host", "machine"} ) func RmCommand() cli.Command { @@ -44,11 +44,16 @@ func deleteResources(ctx *cli.Context) error { } var lastErr error + var envErr error for _, id := range ctx.Args() { resource, err := Lookup(c, id, types...) if err != nil { lastErr = err - fmt.Println(lastErr) + if _, envErr = LookupEnvironment(c, id); envErr != nil { + fmt.Println("Incorrect usage: Use `rancher env rm`.") + } else { + fmt.Println(lastErr) + } continue } @@ -60,7 +65,7 @@ func deleteResources(ctx *cli.Context) error { } } - if lastErr != nil { + if lastErr != nil && envErr == nil { return lastErr } diff --git a/cmd/start.go b/cmd/start.go index ef14196bf7a..d2f62c37e5e 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -43,11 +43,16 @@ func startResources(ctx *cli.Context) error { } var lastErr error + var envErr error for _, id := range ctx.Args() { resource, err := Lookup(c, id, types...) if err != nil { lastErr = err - fmt.Println(lastErr) + if _, envErr = LookupEnvironment(c, id); envErr != nil { + fmt.Println("Incorrect usage: Use `rancher env start`.") + } else { + fmt.Println(lastErr) + } continue } @@ -64,7 +69,7 @@ func startResources(ctx *cli.Context) error { } } - if lastErr != nil { + if lastErr != nil && envErr == nil { return lastErr } diff --git a/cmd/stop.go b/cmd/stop.go index d19a7488d0d..4de3f433b18 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -8,7 +8,7 @@ import ( ) var ( - stopTypes = cli.StringSlice([]string{"service", "container", "host", "account"}) + stopTypes = cli.StringSlice([]string{"service", "container", "host"}) ) func StopCommand() cli.Command { @@ -43,11 +43,16 @@ func stopResources(ctx *cli.Context) error { } var lastErr error + var envErr error for _, id := range ctx.Args() { resource, err := Lookup(c, id, types...) if err != nil { lastErr = err - fmt.Println(lastErr) + if _, envErr = LookupEnvironment(c, id); envErr != nil { + fmt.Println("Incorrect usage: Use `rancher env stop`.") + } else { + fmt.Println(lastErr) + } continue } @@ -69,7 +74,7 @@ func stopResources(ctx *cli.Context) error { } } - if lastErr != nil { + if lastErr != nil && envErr == nil { return lastErr }