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

Method Execute

command/v7/unshare_route_command.go:33–103  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

31}
32
33func (cmd UnshareRouteCommand) Execute(args []string) error {
34 err := cmd.SharedActor.CheckTarget(true, true)
35 if err != nil {
36 return err
37 }
38
39 user, err := cmd.Actor.GetCurrentUser()
40 if err != nil {
41 return err
42 }
43
44 domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequireArgs.Domain)
45 cmd.UI.DisplayWarnings(warnings)
46 if err != nil {
47 return err
48 }
49
50 path := cmd.Path.Path
51 route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0)
52 cmd.UI.DisplayWarnings(warnings)
53 if err != nil {
54 if _, ok := err.(actionerror.RouteNotFoundError); ok {
55 cmd.UI.DisplayText("Can not unshare route:")
56 return err
57 }
58 }
59
60 destinationOrgName := cmd.DestinationOrg
61
62 if destinationOrgName == "" {
63 destinationOrgName = cmd.Config.TargetedOrganizationName()
64 }
65
66 destinationOrg, warnings, err := cmd.Actor.GetOrganizationByName(destinationOrgName)
67 cmd.UI.DisplayWarnings(warnings)
68
69 if err != nil {
70 if _, ok := err.(actionerror.OrganizationNotFoundError); ok {
71 cmd.UI.DisplayText("Can not unshare route:")
72 return err
73 }
74 }
75
76 targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID)
77 cmd.UI.DisplayWarnings(warnings)
78 if err != nil {
79 if _, ok := err.(actionerror.SpaceNotFoundError); ok {
80 cmd.UI.DisplayText("Can not unshare route:")
81 return err
82 }
83 }
84
85 url := desiredURL(domain.Name, cmd.Hostname, path, 0)
86 cmd.UI.DisplayTextWithFlavor("Unsharing route {{.URL}} from space {{.DestinationSpace}} as {{.User}}",
87 map[string]interface{}{
88 "URL": url,
89 "DestinationSpace": cmd.DestinationSpace,
90 "User": user.Name,

Callers

nothing calls this directly

Calls 13

desiredURLFunction · 0.85
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
GetDomainByNameMethod · 0.65
DisplayWarningsMethod · 0.65
GetRouteByAttributesMethod · 0.65
DisplayTextMethod · 0.65
GetOrganizationByNameMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
UnshareRouteMethod · 0.65

Tested by

no test coverage detected