From 4eadb588412af8f2028ed5a71037c45f7caff269 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 4 Apr 2017 13:47:53 +0200 Subject: 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. --- main.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'main.go') 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)", }, ) } -- cgit 1.4.1