3333 Aliases : []string {"c" },
3434 Usage : "A new comment describing the purpose of the virtual network." ,
3535 }
36+ vnetForceDeleteFlag = & cli.BoolFlag {
37+ Name : "force" ,
38+ Aliases : []string {"f" },
39+ Usage : "Force the deletion of the virtual network even if it is being relied upon by other resources. Those" +
40+ "resources will either be deleted (e.g. IP Routes) or moved to the current default virutal network." ,
41+ }
3642)
3743
3844func buildVirtualNetworkSubcommand (hidden bool ) * cli.Command {
@@ -82,6 +88,7 @@ be the current default.`,
8288 UsageText : "cloudflared tunnel [--config FILEPATH] network delete VIRTUAL_NETWORK" ,
8389 Description : `Deletes the virtual network (given its ID or name). This is only possible if that virtual network is unused.
8490A virtual network may be used by IP routes or by WARP devices.` ,
91+ Flags : []cli.Flag {vnetForceDeleteFlag },
8592 Hidden : hidden ,
8693 },
8794 {
@@ -188,7 +195,7 @@ func deleteVirtualNetworkCommand(c *cli.Context) error {
188195 if err != nil {
189196 return err
190197 }
191- if c .NArg () != 1 {
198+ if c .NArg () < 1 {
192199 return errors .New ("You must supply exactly one argument, either the ID or name of the virtual network to delete" )
193200 }
194201
@@ -198,7 +205,12 @@ func deleteVirtualNetworkCommand(c *cli.Context) error {
198205 return err
199206 }
200207
201- if err := sc .deleteVirtualNetwork (vnetId ); err != nil {
208+ forceDelete := false
209+ if c .IsSet (vnetForceDeleteFlag .Name ) {
210+ forceDelete = c .Bool (vnetForceDeleteFlag .Name )
211+ }
212+
213+ if err := sc .deleteVirtualNetwork (vnetId , forceDelete ); err != nil {
202214 return errors .Wrap (err , "API error" )
203215 }
204216 fmt .Printf ("Successfully deleted virtual network '%s'\n " , input )
0 commit comments