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

Method Execute

command/v7/update_route_command.go:40–128  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

38`
39}
40func (cmd UpdateRouteCommand) Execute(args []string) error {
41 err := cmd.SharedActor.CheckTarget(true, true)
42 if err != nil {
43 return err
44 }
45
46 user, err := cmd.Actor.GetCurrentUser()
47 if err != nil {
48 return err
49 }
50
51 domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequiredArgs.Domain)
52 cmd.UI.DisplayWarnings(warnings)
53 if err != nil {
54 return err
55 }
56
57 path := cmd.Path.Path
58
59 route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0)
60 url := desiredURL(domain.Name, cmd.Hostname, path, 0)
61 cmd.UI.DisplayWarnings(warnings)
62
63 if err != nil {
64 if _, ok := err.(actionerror.RouteNotFoundError); !ok {
65 return err
66 }
67 }
68
69 // Update route only works for per route options. The command will fail instead instead of just
70 // ignoring the per-route options like it is the case for create-route and map-route.
71 err = cmd.validateAPIVersionForPerRouteOptions()
72 if err != nil {
73 return err
74 }
75
76 if cmd.Options == nil && cmd.RemoveOptions == nil {
77 return actionerror.RouteOptionSupportError{
78 ErrorText: fmt.Sprintf("No options were specified for the update of the Route %s", route.URL)}
79 }
80
81 if len(cmd.Options) > 0 {
82 routeOpts, wrongOptSpec := resources.CreateRouteOptions(cmd.Options)
83 if wrongOptSpec != nil {
84 return actionerror.RouteOptionError{
85 Name: *wrongOptSpec,
86 DomainName: domain.Name,
87 Path: path,
88 Host: cmd.Hostname,
89 }
90 }
91
92 cmd.UI.DisplayTextWithFlavor("Updating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.User}}...",
93 map[string]interface{}{
94 "URL": url,
95 "User": user.Name,
96 "SpaceName": cmd.Config.TargetedSpace().Name,
97 "OrgName": cmd.Config.TargetedOrganization().Name,

Callers

nothing calls this directly

Calls 15

CreateRouteOptionsFunction · 0.92
RemoveRouteOptionsFunction · 0.92
desiredURLFunction · 0.85
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
GetDomainByNameMethod · 0.65
DisplayWarningsMethod · 0.65
GetRouteByAttributesMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedSpaceMethod · 0.65
TargetedOrganizationMethod · 0.65

Tested by

no test coverage detected