(args []string)
| 38 | ` |
| 39 | } |
| 40 | func (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, |
nothing calls this directly
no test coverage detected