about summary refs log tree commit diff
diff options
context:
space:
mode:
-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))