(app models.Application, route models.Route)
| 95 | } |
| 96 | |
| 97 | func (routeActor routeActor) BindRoute(app models.Application, route models.Route) error { |
| 98 | if !app.HasRoute(route) { |
| 99 | routeActor.ui.Say(T( |
| 100 | "Binding {{.URL}} to {{.AppName}}...", |
| 101 | map[string]interface{}{ |
| 102 | "URL": terminal.EntityNameColor(route.URL()), |
| 103 | "AppName": terminal.EntityNameColor(app.Name), |
| 104 | }), |
| 105 | ) |
| 106 | |
| 107 | err := routeActor.routeRepo.Bind(route.GUID, app.GUID) |
| 108 | switch err := err.(type) { |
| 109 | case nil: |
| 110 | routeActor.ui.Ok() |
| 111 | routeActor.ui.Say("") |
| 112 | return nil |
| 113 | case errors.HTTPError: |
| 114 | if err.ErrorCode() == errors.InvalidRelation { |
| 115 | return errors.New(T( |
| 116 | "The route {{.URL}} is already in use.\nTIP: Change the hostname with -n HOSTNAME or use --random-route to generate a new route and then push again.", |
| 117 | map[string]interface{}{ |
| 118 | "URL": route.URL(), |
| 119 | }), |
| 120 | ) |
| 121 | } |
| 122 | } |
| 123 | return err |
| 124 | } |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | func (routeActor routeActor) UnbindAll(app models.Application) error { |
| 129 | for _, route := range app.Routes { |
no test coverage detected