about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-02-08T17·06+0100
committerVincent Ambo <tazjin@gmail.com>2017-02-08T17·16+0100
commitc046e5acff451eb7beafe64fedf83fad51bb4aca (patch)
treeb2932a104c912f4cebecc2cc6a853ef55ff5ee96 /main.go
parentdd2fdd63e5c1fdaed0eb5116e32724068495fae7 (diff)
feat main: Add 'delete' command
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/main.go b/main.go
index f6e4921435e9..dc320686fbc2 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))