MCPcopy Create free account
hub / github.com/cloudfoundry/cli / BindRoute

Method BindRoute

cf/actors/routes.go:97–126  ·  view source on GitHub ↗
(app models.Application, route models.Route)

Source from the content-addressed store, hash-verified

95}
96
97func (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
128func (routeActor routeActor) UnbindAll(app models.Application) error {
129 for _, route := range app.Routes {

Callers 1

FindAndBindRouteMethod · 0.95

Calls 8

EntityNameColorFunction · 0.92
NewFunction · 0.92
HasRouteMethod · 0.80
SayMethod · 0.65
BindMethod · 0.65
OkMethod · 0.65
ErrorCodeMethod · 0.65
URLMethod · 0.45

Tested by

no test coverage detected