about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-04-04T11·47+0200
committerVincent Ambo <tazjin@gmail.com>2017-04-04T11·49+0200
commit4eadb588412af8f2028ed5a71037c45f7caff269 (patch)
tree223327cdbe8f7d76d620d9c1e7831c34617f2812
parent3b0f41e71d8ff2763ee827d17034b5d929d0c7ff (diff)
fix main: Don't panic if file is unspecified
Instead of printing a spooky stacktrace when the user forgets to specify
the `-f` argument, return an error a lot more gracefully.
-rw-r--r--main.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/main.go b/main.go
index 00d06e7dc0a2..f5af42015057 100644
--- a/main.go
+++ b/main.go
@@ -75,8 +75,11 @@ func applyCommand() cli.Command {
 			include := c.StringSlice("include")
 			exclude := c.StringSlice("exclude")
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
+			if err != nil {
+				return err
+			}
 
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 			if err != nil {
 				return err
 			}
@@ -102,8 +105,11 @@ func replaceCommand() cli.Command {
 			include := c.StringSlice("include")
 			exclude := c.StringSlice("exclude")
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
+			if err != nil {
+				return err
+			}
 
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 			if err != nil {
 				return err
 			}
@@ -122,9 +128,13 @@ func deleteCommand() cli.Command {
 		Action: func(c *cli.Context) error {
 			include := c.StringSlice("include")
 			exclude := c.StringSlice("exclude")
+
 			ctx, err := loadContext(c)
-			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
+			if err != nil {
+				return err
+			}
 
+			resources, err := templater.LoadAndPrepareTemplates(&include, &exclude, ctx)
 			if err != nil {
 				return err
 			}
@@ -186,7 +196,7 @@ func loadContext(c *cli.Context) (*context.Context, error) {
 		return nil, meep.New(
 			&meep.ErrInvalidParam{
 				Param:  "file",
-				Reason: "Cluster config file must be specified",
+				Reason: "Cluster config file must be specified (-f)",
 			},
 		)
 	}