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

Method Execute

command/v7/unmap_route_command.go:35–95  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

33}
34
35func (cmd UnmapRouteCommand) Execute(args []string) error {
36 err := cmd.SharedActor.CheckTarget(true, true)
37 if err != nil {
38 return err
39 }
40
41 user, err := cmd.Actor.GetCurrentUser()
42 if err != nil {
43 return err
44 }
45
46 domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequiredArgs.Domain)
47 cmd.UI.DisplayWarnings(warnings)
48 if err != nil {
49 return err
50 }
51
52 spaceGUID := cmd.Config.TargetedSpace().GUID
53 app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.App, spaceGUID)
54 cmd.UI.DisplayWarnings(warnings)
55 if err != nil {
56 return err
57 }
58
59 path := cmd.Path.Path
60 route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, cmd.Port)
61 url := desiredURL(domain.Name, cmd.Hostname, path, cmd.Port)
62 cmd.UI.DisplayWarnings(warnings)
63 if err != nil {
64 return err
65 }
66
67 cmd.UI.DisplayTextWithFlavor("Removing route {{.URL}} from app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.User}}...", map[string]interface{}{
68 "URL": url,
69 "AppName": cmd.RequiredArgs.App,
70 "User": user.Name,
71 "SpaceName": cmd.Config.TargetedSpace().Name,
72 "OrgName": cmd.Config.TargetedOrganization().Name,
73 })
74
75 destination, err := cmd.Actor.GetRouteDestinationByAppGUID(route, app.GUID)
76 if err != nil {
77 if _, ok := err.(actionerror.RouteDestinationNotFoundError); ok {
78 cmd.UI.DisplayText("Route to be unmapped is not currently mapped to the application.")
79 cmd.UI.DisplayOK()
80 return nil
81 }
82
83 return err
84 }
85
86 warnings, err = cmd.Actor.UnmapRoute(route.GUID, destination.GUID)
87 cmd.UI.DisplayWarnings(warnings)
88 if err != nil {
89 return err
90 }
91
92 cmd.UI.DisplayOK()

Callers

nothing calls this directly

Calls 14

desiredURLFunction · 0.85
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
GetDomainByNameMethod · 0.65
DisplayWarningsMethod · 0.65
TargetedSpaceMethod · 0.65
GetRouteByAttributesMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
DisplayTextMethod · 0.65

Tested by

no test coverage detected