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

Method Execute

command/v7/delete_route_command.go:36–88  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

34}
35
36func (cmd DeleteRouteCommand) Execute(args []string) error {
37 err := cmd.SharedActor.CheckTarget(true, false)
38 if err != nil {
39 return err
40 }
41
42 _, err = cmd.Actor.GetCurrentUser()
43 if err != nil {
44 return err
45 }
46
47 url := desiredURL(cmd.RequiredArgs.Domain, cmd.Hostname, cmd.Path.Path, cmd.Port)
48
49 cmd.UI.DisplayText("This action impacts all apps using this route.")
50 cmd.UI.DisplayText("Deleting this route will make apps unreachable via this route.")
51
52 if !cmd.Force {
53 response, promptErr := cmd.UI.DisplayBoolPrompt(false, "Really delete the route {{.URL}}?", map[string]interface{}{
54 "URL": url,
55 })
56
57 if promptErr != nil {
58 return promptErr
59 }
60
61 if !response {
62 cmd.UI.DisplayText("'{{.URL}}' has not been deleted.", map[string]interface{}{
63 "URL": url,
64 })
65 return nil
66 }
67 }
68
69 cmd.UI.DisplayTextWithFlavor("Deleting route {{.URL}}...",
70 map[string]interface{}{
71 "URL": url,
72 })
73
74 warnings, err := cmd.Actor.DeleteRoute(cmd.RequiredArgs.Domain, cmd.Hostname, cmd.Path.Path, cmd.Port)
75
76 cmd.UI.DisplayWarnings(warnings)
77 if err != nil {
78 if _, ok := err.(actionerror.RouteNotFoundError); ok {
79 cmd.UI.DisplayText(`Unable to delete. ` + err.Error())
80 cmd.UI.DisplayOK()
81 return nil
82 }
83 return err
84 }
85
86 cmd.UI.DisplayOK()
87 return nil
88}

Callers

nothing calls this directly

Calls 10

desiredURLFunction · 0.85
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextMethod · 0.65
DisplayBoolPromptMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
DeleteRouteMethod · 0.65
DisplayWarningsMethod · 0.65
ErrorMethod · 0.65
DisplayOKMethod · 0.65

Tested by

no test coverage detected