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

Method Execute

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

Source from the content-addressed store, hash-verified

31}
32
33func (cmd MoveRouteCommand) 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 transfer ownership of 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 if err != nil {
69 if _, ok := err.(actionerror.OrganizationNotFoundError); ok {
70 cmd.UI.DisplayText("Can not transfer ownership of route:")
71 return err
72 }
73 }
74
75 targetedSpace, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.DestinationSpace, destinationOrg.GUID)
76 cmd.UI.DisplayWarnings(warnings)
77 if err != nil {
78 if _, ok := err.(actionerror.SpaceNotFoundError); ok {
79 cmd.UI.DisplayText("Can not transfer ownership of route:")
80 return err
81 }
82 }
83
84 url := desiredURL(domain.Name, cmd.Hostname, path, 0)
85 cmd.UI.DisplayTextWithFlavor("Move ownership of route {{.URL}} to space {{.DestinationSpace}} as {{.User}}",
86 map[string]interface{}{
87 "URL": url,
88 "DestinationSpace": cmd.DestinationSpace,
89 "User": user.Name,
90 })

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
MoveRouteMethod · 0.65

Tested by

no test coverage detected