MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Execute

Method Execute

command/v7/delete_command.go:18–87  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

16}
17
18func (cmd DeleteCommand) Execute(args []string) error {
19 err := cmd.SharedActor.CheckTarget(true, true)
20 if err != nil {
21 return err
22 }
23
24 currentUser, err := cmd.Actor.GetCurrentUser()
25 if err != nil {
26 return err
27 }
28
29 if !cmd.Force {
30 prompt := "Really delete the app {{.AppName}}?"
31 if cmd.DeleteMappedRoutes {
32 prompt = "Really delete the app {{.AppName}} and associated routes?"
33 cmd.UI.DisplayText("Deleting the app and associated routes will make apps with this route, in any org, unreachable.")
34 }
35
36 response, promptErr := cmd.UI.DisplayBoolPrompt(false, prompt, map[string]interface{}{
37 "AppName": cmd.RequiredArgs.AppName,
38 })
39
40 if promptErr != nil {
41 return promptErr
42 }
43
44 if !response {
45 cmd.UI.DisplayText("App '{{.AppName}}' has not been deleted.", map[string]interface{}{
46 "AppName": cmd.RequiredArgs.AppName,
47 })
48 return nil
49 }
50 }
51
52 cmd.UI.DisplayTextWithFlavor("Deleting app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
53 "AppName": cmd.RequiredArgs.AppName,
54 "OrgName": cmd.Config.TargetedOrganization().Name,
55 "SpaceName": cmd.Config.TargetedSpace().Name,
56 "Username": currentUser.Name,
57 })
58
59 warnings, err := cmd.Actor.DeleteApplicationByNameAndSpace(
60 cmd.RequiredArgs.AppName,
61 cmd.Config.TargetedSpace().GUID,
62 cmd.DeleteMappedRoutes,
63 )
64 cmd.UI.DisplayWarnings(warnings)
65 if err != nil {
66 switch err.(type) {
67 case actionerror.ApplicationNotFoundError:
68 cmd.UI.DisplayWarning("App '{{.AppName}}' does not exist.", map[string]interface{}{
69 "AppName": cmd.RequiredArgs.AppName,
70 })
71 case actionerror.RouteBoundToMultipleAppsError:
72 cmd.UI.DeferText(
73 "\nTIP: Run 'cf delete {{.AppName}}' to delete the app and 'cf delete-route' to delete the route.",
74 map[string]interface{}{
75 "AppName": cmd.RequiredArgs.AppName,

Callers

nothing calls this directly

Calls 12

CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextMethod · 0.65
DisplayBoolPromptMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
TargetedSpaceMethod · 0.65
DisplayWarningsMethod · 0.65
DisplayWarningMethod · 0.65
DeferTextMethod · 0.65
DisplayOKMethod · 0.65

Tested by

no test coverage detected