From c046e5acff451eb7beafe64fedf83fad51bb4aca Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 8 Feb 2017 18:06:47 +0100 Subject: [PATCH] feat main: Add 'delete' command --- main.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.go b/main.go index f6e492143..dc320686f 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ func main() { templateCommand(), applyCommand(), replaceCommand(), + deleteCommand(), } app.Run(os.Args) @@ -109,6 +110,27 @@ func replaceCommand() cli.Command { } } +func deleteCommand() cli.Command { + return cli.Command{ + Name: "delete", + Usage: "Interpolate templates and run 'kubectl delete'", + Flags: commonFlags(), + 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 + } + + args := []string{"delete", "-f", "-"} + return runKubectlWithResources(ctx, &args, &resources) + }, + } +} + func runKubectlWithResources(c *context.Context, kubectlArgs *[]string, resources *[]string) error { args := append(*kubectlArgs, fmt.Sprintf("--context=%s", c.Name))