feat main: Add 'delete' command
This commit is contained in:
		
							parent
							
								
									dd2fdd63e5
								
							
						
					
					
						commit
						c046e5acff
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		
							
								
								
									
										22
									
								
								main.go
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								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)) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue